There is a ViewController, inside of which it is necessary to arrange three Pickers of the same width in a row. How to implement it?
- I understand that the author of the question wanted the pickers to be evenly distributed across the entire width of the parent taking any place under any screen - Max Mikheyenko
|
3 answers
Left picker:
- left margin indent from parent's left edge = 0 (leading edge)
- width of the left is equal to the width of the average (equal width)
Average picker:
- leading average picker = trailing left picker
- width of the average is equal to the width of the right (equal width)
Right picker:
- indent from the right edge of the parent = 0 (trailing edge)
- leading right picker = trailing average picker
|
NSInteger numberOfPickers = 3; CGFloat pickerWidth = self.view.frame.size.width/numberOfPickers; for(int i =0; i< numberOfPickers; i++) { CGRect frame = CGRectMake(i*pickerWidth, 0, pickerWidth, 100); UIPickerView *picker = [UIPickerView alloc] initWithFrame:frame]; [self.view addSubview:picker]; } - Is it possible to do this somehow not programmatically? I write on swift - amazingbasil
- What is the problem then? In IB, add three UIPickerViews and give them the desired width and height. - Vitali Eller
|
- If you want to do only in IB, then use UIStackView .
- If you want to do in the code, then use UILayoutGuide .
|
