Note that there are some explanatory texts on larger screens.

plurals
  1. POIs it possible to provide a UIView to a UIPickerView that 'fills' the row?
    primarykey
    data
    text
    <p>I am trying to provide custom views to a UIPickerView so that the entire background of each row is one of two colours (none of which are white).</p> <p>I have been able to provide these custom views ok, with the colours I want, but I can't make the view fill the entire 'space' for the row.</p> <p>The test code below is trying to achieve the effect of changing the background colour of the UIPicker to green - but the view I provide does not get aligned correctly. It is always a few pixels to the left and sometimes actually covers the left edge of the component depending on its width.</p> <p>The effect of this is that I always see a white edge on the right hand side.</p> <p>Changing the origin of the CGRect does not change its location in the row.</p> <p>Changing the width of the CGRect changes the width ok but it is still always aligned a few pixels towards the left. i.e. not centered.</p> <p>Can anyone please tell me what am I doing wrong here?</p> <p>I just have a standard UIPicker dropped on to a view.</p> <pre><code>- (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component { return 44; } - (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component { return 200; } - (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view { UIView *rowView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 44)] autorelease]; rowView.backgroundColor = [UIColor greenColor]; return rowView; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload