Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To handle both vertical and horizontal alignment as well as color of placeholder in iOS7. drawInRect and drawAtPoint no longer use current context fillColor.</p> <p><a href="https://developer.apple.com/library/ios/documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/CustomTextProcessing/CustomTextProcessing.html" rel="nofollow noreferrer">https://developer.apple.com/library/ios/documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/CustomTextProcessing/CustomTextProcessing.html</a></p> <p>Obj-C </p> <pre><code>@interface CustomPlaceHolderTextColorTextField : UITextField @end @implementation CustomPlaceHolderTextColorTextField : UITextField -(void) drawPlaceholderInRect:(CGRect)rect { if (self.placeholder) { // color of placeholder text UIColor *placeHolderTextColor = [UIColor redColor]; CGSize drawSize = [self.placeholder sizeWithAttributes:[NSDictionary dictionaryWithObject:self.font forKey:NSFontAttributeName]]; CGRect drawRect = rect; // verticially align text drawRect.origin.y = (rect.size.height - drawSize.height) * 0.5; // set alignment NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init]; paragraphStyle.alignment = self.textAlignment; // dictionary of attributes, font, paragraphstyle, and color NSDictionary *drawAttributes = @{NSFontAttributeName: self.font, NSParagraphStyleAttributeName : paragraphStyle, NSForegroundColorAttributeName : placeHolderTextColor}; // draw [self.placeholder drawInRect:drawRect withAttributes:drawAttributes]; } } @end </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload