In my project, I am using UIActionSheet
for displaying for some sorting type. I want to change the color of the text displayed in the action sheet buttons. How can we change the text color?
相关问题
- 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
- Get the NSRange for the visible text after scroll
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- Swift - hide pickerView after value selected
- How do you detect key up / key down events from a
- didBeginContact:(SKPhysicsContact *)contact not in
- Attempt to present UIAlertController on View Contr
iOS 8:
UIActionSheet
is deprecated.UIAlertController
respects-[UIView tintColor]
, so this works:Better yet, set the whole window's tint color in your application delegate:
iOS 7: In your action sheet delegate, implement
-willPresentActionSheet:
as follows:This works for me in iOS8
If ever you want to go through the
UIActionSheet
's subviews, you should not directly set the text color of theUILabel
but use theUIButton
setTitleColor:forState
method instead. Otherwise, the initial color will be set back upon events like UIControlEventTouchDragOutside for example.Here is the proper way to do it, reusing the jrc's code:
use this for ios 8 and above
UIAppearance can handle this:
Much easier than going through the subviews, but I haven't tested this solution on iOS 6 or earlier.
May be a late answer but I figure it could help someone.
iOS 8: You could simply initialize your UIAlertAction with the style: UIAlertActionStyleDestructive like so:
This will make the button's text red by default.