ios - Multiple font sizes for UITextField placeholder text -
i have placeholder text uitextfield 1 part should have larger font size rather rest of placeholder text. can using attributedplaceholder property ? not seems respect font size adding through attributed string.
currently trying 1 font size , not seems work either ,
nsattributedstring *placeholder = [[nsattributedstring alloc] initwithstring:placeholdertext attributes:@{nsfontattributename : [uifont fontwithname:textfield.font.fontname size:8.0]}]; textfield.attributedplaceholder = placeholder;
currently don't think possible attributedplaceholder
. setattributedtext
possible doing following
uifont *futurafont = [uifont fontwithname:@"futura" size:18.0]; nsdictionary *futuradictionary = [nsdictionary dictionarywithobject: futurafont forkey:nsfontattributename]; nsmutableattributedstring *fattrstring = [[nsmutableattributedstring alloc] initwithstring:title attributes: futuradictionary]; uifont *menlofont = [uifont fontwithname:@"menlo" size:12.0]; nsdictionary *menlodictionary = [nsdictionary dictionarywithobject:menlofont forkey:nsfontattributename]; nsmutableattributedstring *mattrstring = [[nsmutableattributedstring alloc]initwithstring:title2 attributes:menlodictionary]; [mattrstring addattribute:nsforegroundcolorattributename value:[uicolor blackcolor] range:(nsmakerange(0, [title2 length]))]; [fattrstring appendattributedstring:mattrstring]; uitextfield *textfield = [[uitextfield alloc] initwithframe:cgrectmake(0, 200, 320, 100)]; [textfield setallowseditingtextattributes:yes]; [textfield setattributedtext:fattrstring]; [self.view addsubview:textfield];
Comments
Post a Comment