簡體   English   中英

iOS UITextView類別設置字體

[英]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類參考:

http://developer.apple.com/library/ios/#documentation/uikit/reference/UIFont_Class/Reference/Reference.html

UIColor類參考:

http://developer.apple.com/library/ios/#documentation/uikit/reference/UIColor_Class/Reference/Reference.html

將這些行添加到您的standardize方法中:

self.textColor = [UIColor ...]; // whatever color you want
self.font = [UIFont ...]; // whatever font you want

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM