I'm aware of the pickerView:viewForRow:forComponent:reusingView
method, but when using the view
it passes in reusingView:
how do I change it to use a different text color? If I use view.backgroundColor = [UIColor whiteColor];
none of the views show up anymore.
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
- “Zero out” sensitive String data in Swift
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- xcode 4 garbage collection removed?
- Unable to process app at this time due to a genera
- Swift - hide pickerView after value selected
- How can I add media attachments to my push notific
Swift 4 (Update to the accepted answer)
in Xamarin, override the UIPickerModelView method GetAttributedTitle
I ran into the same problem with a pickerView using two components. My solution is similar to above with a few modifications. Because I am using two components it is necessary to pull from two different arrays.
There is a function in the delegate method that is more elegant:
Objective-C:
If you want to change the selection bar colors as well, I found that I had to add 2 separate
UIViews
to the view containing theUIPickerView
, spaced 35 pts apart for a picker height of 180.Swift 3:
Swift 4:
Swift 4.2:
Remember when you use the method: You don't need to implement
titleForRowInComponent()
as it is never called when usingattributedTitleForRow()
.