無標(biāo)題文章

attributedPlaceholder

NSString *string = @"手機(jī)號(hào)";
NSMutableAttributedString *placeholder = [[NSMutableAttributedString alloc] initWithString:string];
[placeholder setAttributes:@{
NSFontAttributeName:[UIFont systemFontOfSize:14],
NSForegroundColorAttributeName:[UIColor whiteColor]
} range:NSMakeRange(0, 2)];
self.loginPhoneNumber.attributedPlaceholder = placeholder;

繼承TextField并重寫
  • (void)drawPlaceholderInRect:(CGRect)rect
    {
    [self.placeholder drawInRect:CGRectMake(0, 10, rect.size.width, 25) withAttributes:@{
    NSFontAttributeName : self.font,
    NSForegroundColorAttributeName : [UIColor grayColor]
    }];
    }
不得姐.gif
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 1、設(shè)置UILabel行間距 NSMutableAttributedString*attrString=[[NSM...
    iOS祎閱讀 2,383評(píng)論 0 0
  • iOS使用NSMutableAttributedString 實(shí)現(xiàn)富文本(不同顏色字體、下劃線等) 在iOS開發(fā)中...
    VickyLanLan閱讀 222評(píng)論 0 1
  • //// AddressBookViewController.h// QRCodeScanApp//// Crea...
    奇怪的知識(shí)增加了閱讀 346評(píng)論 0 0
  • 諸位看官,上次我們講到,關(guān)河君整理了一下自來熟的代碼,發(fā)現(xiàn)這家伙,好吧,我們還是來給他命個(gè)名吧,對(duì),那家伙就叫阿晨...
    風(fēng)雪關(guān)河閱讀 243評(píng)論 0 1
  • 我沒去過外面的世界 我不知道鳥兒思家的時(shí)候會(huì)干嘛 不知道魚兒寂寞的時(shí)候會(huì)想什么 不知道樹木是否也像我一樣 為某個(gè)人...
    唐云杉閱讀 256評(píng)論 0 0

友情鏈接更多精彩內(nèi)容