iOS settings Uitextfield placeholder size color

Source: Internet
Author: User

Demand: Product placeholder font is too large, color is too obvious, the requirements and normal input font and color is different

Method: Set the size and color of the placeholder, actually set the size and color of the placeholder label, but when the settings are finished, the placeholder font is a bit biased, so set the properties.

     //set the font size for placeholder[Titlefield Setvalue:[uifont Systemfontofsize: -] Forkeypath:@"_placeholderlabel.font"]; //set the font color for placeholder[Titlefield Setvalue:[uicolor Redcolor] Forkeypath:@"_placeholderlabel.textcolor"]; //Placeholder Center DisplayNsmutableparagraphstyle *style =[Titlefield.defaulttextattributes[nsparagraphstyleattributename] mutablecopy]; Style.minimumlineheight= TitleField.font.lineHeight-(TitleField.font.lineHeight-[Uifont systemfontofsize: -].lineheight)/2; Titlefield.attributedplaceholder= [[Nsattributedstring alloc] initwithstring:@"Please enter a title here"Attributes:@{nsparagraphstyleattributename:style}];

Problem: The input text is not centered, placeholder is not centered
Method: Rewrite! Rewrite to solve all the problems!

-(CGRect) Editingrectforbounds: (CGRect) Bounds-(CGRect) Placeholderrectforbounds: (CGRect) bounds

  



iOS settings Uitextfield placeholder size color

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.