我想的UILabel的第一个字母有从别人不同的字体大小,几个字体大小。需要一些指导如何做到这一点。这个标签有很多单词。增加第一个字母的字体大小UILabel.text
这是我曾尝试:
NSArray * words = [Label.text componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
NSString *firstLetter = [[words objectAtIndex:0] substringToIndex:1];
但被困在增加的NSString的大小。有没有更好的办法?我欢迎建议和指导..谢谢..
编辑:
[Label setFont:[UIFont fontWithName:@"Arial" size:12.f]];
NSArray * words = [Label.text componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
UIFont *fontFirst=[UIFont fontWithName:@"Arial" size:15.f];
NSDictionary *attrsDictFirst=[NSDictionary dictionaryWithObject:font forKey:NSFontAttributeName];
NSAttributedString *finalString=[[NSAttributedString alloc] initWithString:[[words objectAtIndex:0] substringToIndex:1] attributes:attrsDictFirst];
如果您只需要iOS 6或更高版本,请使用'UILabel attributedText'。如果您需要支持iOS 5或更早版本,那么您不能在UILabel中使用多个字体。 – rmaddy
我怀疑你必须使用属性文本。 (或将其分成两个标签。) –