【发布时间】:2016-03-07 18:05:12
【问题描述】:
我是编程新手,我正在尝试创建一个类来设置大小、属性、颜色和对齐文本中心,因为我正在使用以下代码。我正在尝试做更多的事情,但是一旦我知道如何设置该类,就可以进行修改。
请帮忙。
@implementation OceansTabController
@synthesize textField;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.textField.text = @"\"The sea, once it casts its spell, holds one in its net of wonder forever.\"\nJacques Yves Cousteau\n\nOur majestic oceans\n\n";
NSMutableAttributedString *attString=[[NSMutableAttributedString alloc] initWithString:textField.text];
//
// UIFont *font_regular=[UIFont fontWithName:@"HelveticaNeue" size:14.0f];
UIFont *font=[UIFont fontWithName:@"HelveticaNeue" size:14.0f];
UIFont *font_italic=[UIFont fontWithName:@"HelveticaNeue-Italic" size:14.0f];
UIFont *font_bold=[UIFont fontWithName:@"HelveticaNeue-Bold" size:14.0f];
UIFont *font_boldBlue=[UIFont fontWithName:@"HelveticaNeue-Bold" size:14.0f];
UIFont *font_boldLarge=[UIFont fontWithName:@"HelveticaNeue-Bold" size:16.0f];
UIFont *font_boldLargeCentered=[UIFont fontWithName:@"HelveticaNeue-Bold" size:16.0f];
[attString addAttribute:NSFontAttributeName value:font_italic range:NSMakeRange(0, 75)];
[attString addAttribute:NSFontAttributeName value:font_boldBlue range:NSMakeRange(76, 21)];
[attString addAttribute:NSFontAttributeName value:font_boldLargeCentered range:NSMakeRange(98, 20)];
【问题讨论】:
标签: ios objective-c uitextview uifont