Re: [問題] 請教一下ui介面有辦法寫出'上下標'嗎?
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)
推
05/15 21:48, , 1F
05/15 21:48, 1F
→
05/15 21:49, , 2F
05/15 21:49, 2F
討論串 (同標題文章)
完整討論串 (本文為第 4 之 4 篇):
MacDev 近期熱門文章
PTT數位生活區 即時熱門文章