Does anyone know what color a UITextField
's placeholder text is, by default? I'm trying to set a UITextView
's text to the same color. I've read elsewhere that it is UIColor.lightGrayColor()
but it is actually a little lighter.
相关问题
- 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
Starting from iOS 13 you should use
UIColor.placeholderText
to make sure the element looks good in both light and dark modes. Documentation:You can get this colour from inspecting the
attributedPlaceholder
from theUITextField
.The default seems to be:
NSColor = "UIExtendedSRGBColorSpace 0 0 0.0980392 0.22";
You could add an extension (or category) on
UIColor
:2018, latest syntax is just:
#colorLiteralRed
was deprecated. Be aware of this in some cases.I think you can get the color by use the tools in your Mac.
Better to grab the color off of a text field dynamically in case it changes in the future. Default to 70% gray, which is pretty close
Set label font to "light"
mylabel.font = [UIFont fontWithName:@"HelveticaNeue-Light" size:14.0f];
and color code for placeholder text is
#c2b098
According to the Apple code, it is 70% gray
and if we convert it to rgb :