Change settings text box placeholder text and pictures

Source: Internet
Author: User
Tags change settings uikit

If we want to achieve this effect, click on the corresponding text, placeholder text display highlighting, and other text boxes are not highlighted by the corresponding code
#import<UIKit/UIKit.h>@interfaceXmgtextfield:uitextfield/** Color*/@property (nonatomic,strong) Uicolor*Placeholdercolor;@end#import "XMGTextField.h"#import<objc/runtime.h>StaticNSString *ConstXmgpacerholdercolorkeypath=@"_placeholderlabel.textcolor";@implementationXmgtextfield////-(void) Drawplaceholderinrect: (cgrect) rect{//[Self.placeholder drawinrect:cgrectmake (0, ten, rect.size.width,) withattributes:@{ Nsforegroundcolorattributename:[uicolor Graycolor],//NSFontAttributeName:self.font//                                                       }];//}/** Runtime: Apple's official C-language library can do a lot of low-level operations (such as accessing hidden member variables \ member methods)*/-(void) awakefromnib{//set the cursor color to match the text colorSelf.tintcolor=Self.textcolor; //No first responders .[self resignfirstresponder];}/** * The current text box loses focus is called*/-(BOOL) resignfirstresponder{//Modify placeholder text color[self Setvalue:[uicolor graycolor] Forkeypath:xmgpacerholdercolorkeypath]; return[Super Resignfirstresponder];}/** * The current text box gathers focus will be called*/-(BOOL) becomefirstresponder{[self setValue:self.textColor forkeypath:xmgpacerholdercolorkeypath]; return[Super Becomefirstresponder];}-(void) Setplaceholdercolor: (Uicolor *) placeholdercolor{_placeholdercolor=Placeholdercolor; //Modify placeholder text color[self Setvalue:placeholdercolor Forkeypath:xmgpacerholdercolorkeypath];}@end

Change settings text box placeholder text and pictures

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.