一,效果圖。 二,代碼。 ...
一,效果圖。
二,代碼。
![複製代碼](http://common.cnblogs.com/images/copycode.gif)
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[self.view addSubview:[self getTileLabel:@"你好!"]];
}
//導航條的標題
-(UILabel *)getTileLabel:(NSString *)title{
UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 100 , 200, 44)];
titleLabel.backgroundColor = [UIColor redColor];
titleLabel.font=[UIFont boldSystemFontOfSize:18];
titleLabel.textColor=[UIColor greenColor];
titleLabel.textAlignment = NSTextAlignmentCenter;
titleLabel.text=title;
return titleLabel;
}
![複製代碼](http://common.cnblogs.com/images/copycode.gif)