-1

I created a category class which standardize the feel and look of UITextView. I manage to add border with the code below but not sure how to set font name, font color.

#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
4

2 回答 2

3

This method should work for you:

-(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];
}

These should help too.

UIFont class reference:

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

UIColor class reference:

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

于 2013-01-03T22:15:29.430 回答
1

Add these lines to your standardize method:

self.textColor = [UIColor ...]; // whatever color you want
self.font = [UIFont ...]; // whatever font you want
于 2013-01-03T22:14:19.547 回答