看板 MacDev 關於我們 聯絡資訊
UILabel *lbl = [[UILabel alloc] initWithFrame:CGRectMake(10 , 10, 300, 300)]; [lbl setFont:[UIFont boldSystemFontOfSize:30.0]]; NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:@"H2O"]; NSRange range = NSMakeRange(1, 1); UIFont *smallFont = [UIFont boldSystemFontOfSize:20.0]; NSDictionary *attr = @{(NSString*)kCTSuperscriptAttributeName : @(-1), (NSString*)kCTFontAttributeName : smallFont, NSForegroundColorAttributeName : [UIColor redColor]}; [string addAttributes:attr range:range]; lbl.attributedText = string; [self.view addSubview:lbl]; -- ★ ★ ██ █ █ 一眨眼間你又 CHECK IT OUT █ █ █ ◢█◣ ▄▌ 不要再看路過的女人們了 █▅ █▅█ ▌ ▌▄▌ ▁▁ ▁▁ ▁▁ █ █ █ ◥█◤ ▌ ◢▃▃▃▃▃▃▃▃▃▃▃▃█▃▎█ ▎█ ▎ ▎▃▃▃▃ ██ █ █ ▄ █ ▎█▁▎█▁▎ ▎ ◥▅▅▅ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 211.75.166.176 ※ 編輯: tom19830924 來自: 211.75.166.176 (05/15 12:06)
bloodera:成功了,感謝tom19830924大 05/15 21:48
bloodera:改用 NSForegroundColorAttributeName 就成了 05/15 21:49