[英]IOS UITextView category set font
我創建了一個類別類,用於標准化UITextView的外觀。 我設法用下面的代碼添加邊框,但不確定如何設置字體名稱,字體顏色。
#import "UITextView+Form.h"
#import <QuartzCore/QuartzCore.h>
@implementation UITextView (Form)
-(void)standardize{
CALayer *thisLayer = self.layer;
thisLayer.borderWidth=3.0;
thisLayer.borderColor=[UIColor blackColor].CGColor;
}
@end
此方法應為您工作:
-(void)standardize{
CALayer *thisLayer = self.layer;
thisLayer.borderWidth=3.0;
thisLayer.borderColor=[UIColor blackColor].CGColor;
// Set whatever point size you want
self.font = [UIFont systemFontOfSize:10.0f];
// Set whatever color you want
self.textColor = [UIColor black];
}
這些也應該有所幫助。
UIFont類參考:
UIColor類參考:
將這些行添加到您的standardize
方法中:
self.textColor = [UIColor ...]; // whatever color you want
self.font = [UIFont ...]; // whatever font you want
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.