As illustrated in this picture, I need to add an image next to my picker view entries, it's a picker view that is added to a UITextfield
, what is needed is adding an image in place of the blue triangle, an image next to each option, how to do this?
I found solutions for this in objective-C, but found nothing for swift.
I will pick the first answer as the answer for this question and vote up for any useful comment..
Thanks.
With a picker view you either provide a title for each item, or a custom view for each item. If you want an image combined with text you should provide a custom view.
You need to implement the pickerView:viewForRow:forComponent:reusingView:
method in your picker's data source. You'll need to provide a view that contains an image view and a label. You can either create that in code or load a new one from an XIB file each time you need to create one. I don't have any ready-made code for you, but this isn't that difficult.