繁体   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