How to change color of selected row in UIPickerView

前端 未结 10 885
孤独总比滥情好
孤独总比滥情好 2020-12-03 10:25

Ok, maybe I\'m missing something really simple and I apologize if that\'s the case, however, I\'ve googled every permutation of the title and have not found! So this is sim

10条回答
  •  遥遥无期
    2020-12-03 11:08

    // CGRectMake values for the frame we’d like

    UIPickerView *myPickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0,0, self.view.bounds.size.width, self.view.bounds.size.height)];
    
    // add the UIPickerView to your viewcontroller [mainView addSubview:myPickerView];
    
    // set the selectionindicator to none myPickerView.showsSelectionIndicator = NO;
    

    // define the image that we would like to use

    UIImage *selectorImage = [UIImage imageNamed:@"selectionIndicator.png"];
    
    UIView *customSelector = [[UIImageView alloc] initWithImage:selectorImage];
    

    // set the x and y values to the point on the UIPickerView where you want to place the image

    // set the width and height values to the width and height of your image

    customSelector.frame = CGRectMake(10,(myPickerView.bounds.size.height / 2) + 16, self.view.bounds.size.width – 10, 47);
    

    // add the custom selectionIndicator also to the same viewcontroller

    [mainView addSubview:customSelector];
    

提交回复
热议问题