- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[self initWithOtherUI];
}
- (void)initWithOtherUI
{
// 1.生成一张以后用于平铺的小图片
CGSize size = CGSizeMake(self.view.bounds.size.width, 35);
UIGraphicsBeginImageContextWithOptions(size, NO, 0);
// 2.画矩形
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGFloat height = 35;
CGContextAddRect(ctx, CGRectMake(0, 0, self.view.bounds.size.width, height));
[[UIColor whiteColor] set];
CGContextFillPath(ctx);
// 3.画线条
CGFloat lineWidth = 2;
CGFloat lineY = height - lineWidth;
CGFloat lineX = 20;
CGContextMoveToPoint(ctx, lineX, lineY);
CGContextAddLineToPoint(ctx, self.view.bounds.size.width-40, lineY);
[[UIColor blackColor] set];
CGContextStrokePath(ctx);
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIColor *color = [UIColor colorWithPatternImage:image];
self.view.backgroundColor = color;
}