{"id":574,"date":"2014-06-05T11:22:30","date_gmt":"2014-06-05T03:22:30","guid":{"rendered":"http:\/\/www.yusian.com\/blog\/?p=574"},"modified":"2016-07-15T15:27:33","modified_gmt":"2016-07-15T07:27:33","slug":"uilabel%e4%b8%ad%e6%96%87%e5%ad%97%e9%97%b4%e9%9a%94%e8%b0%83%e6%95%b4","status":"publish","type":"post","link":"https:\/\/www.yusian.com\/blog\/project\/2014\/06\/05\/112230574.html","title":{"rendered":"UILabel\u4e2d\u6587\u5b57\u95f4\u9694\u8c03\u6574"},"content":{"rendered":"<p>1\u3001\u521b\u5efaUILabel\u53ca\u4f4d\u7f6e\u5927\u5c0f\u6dfb\u52a0\u5230View\u7b49\uff08\u7565\uff09<\/p>\n<p>2\u3001\u8bbe\u7f6e\u57fa\u7840\u6587\u672c\u5b57\u7b26\u4e32<br \/>\nNSString *labelText = @&#8221;1\u3001abcdefg \\n2\u30011234567&#8243;;<\/p>\n<p>3\u3001\u8bbe\u7f6e\u53ef\u53d8\u5c5e\u6027\u5b57\u7b26\u4e32<br \/>\nNSMutableAttributedString *attributeText = [[NSMutableAttributedString alloc] initWithString:labelText];<\/p>\n<p>4\u3001\u8bbe\u7f6e\u6587\u5b57\u6837\u5f0f<br \/>\nNSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];<br \/>\n[style setLineSpacing:10];    \/\/ \u884c\u95f4\u8ddd10\u4e2a\u50cf\u7d20<\/p>\n<p>5\u3001\u5b57\u7b26\u4e32\u5e94\u7528\u6837\u5f0f<br \/>\n[attributeText addAttribute:NSParagraphStyleAttributeName value:style range:NSMakeRange(0, [labelText length])];<\/p>\n<p>6\u3001\u8bbe\u7f6eUILabel\u6587\u672c<br \/>\nlabel.attributedText = attributeText;    \/\/ \u6ce8\u610f\uff1a\u4e0d\u80fd\u8bbe\u7f6elabel.text = attributeText<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1\u3001\u521b\u5efaUILabel\u53ca\u4f4d\u7f6e\u5927\u5c0f\u6dfb\u52a0\u5230View\u7b49\uff08\u7565\uff09 2\u3001\u8bbe\u7f6e\u57fa\u7840\u6587\u672c\u5b57\u7b26\u4e32 NSString *labelText = @&#8221;1\u3001abcdefg \\n2\u30011234567&#8243;; 3\u3001\u8bbe\u7f6e\u53ef\u53d8\u5c5e\u6027\u5b57\u7b26\u4e32 NSMutableAttributedString *attributeText = [[NSMutableAttributedString alloc] initWithString:labelText]; 4\u3001\u8bbe\u7f6e\u6587\u5b57\u6837\u5f0f NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init]; [style setLineSpacing:10]; \/\/ \u884c\u95f4\u8ddd10\u4e2a\u50cf\u7d20 5\u3001\u5b57\u7b26\u4e32\u5e94\u7528\u6837\u5f0f [attributeText addAttribute:NSParagraphStyleAttributeName value:style range:NSMakeRange(0, [labelText length])]; 6\u3001\u8bbe\u7f6eUILabel\u6587\u672c label.attributedText = attributeText; \/\/ \u6ce8\u610f\uff1a\u4e0d\u80fd\u8bbe\u7f6elabel.text = attributeText<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[20],"class_list":["post-574","post","type-post","status-publish","format-standard","hentry","category-project","tag-basics"],"_links":{"self":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/posts\/574","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/comments?post=574"}],"version-history":[{"count":0,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/posts\/574\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/media?parent=574"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/categories?post=574"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/tags?post=574"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}