0
点赞
收藏
分享

微信扫一扫

(IOS)UIView背景颜色渐变

他说Python 2021-09-29 阅读 43

UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 100)];

[self.view addSubview:view];

CAGradientLayer *gradient = [CAGradientLayer layer];

gradient.frame = view.bounds;

gradient.colors = [NSArray arrayWithObjects:(id)[[UIColor blackColor] CGColor], (id)[[UIColor whiteColor] CGColor],nil];

[view.layer insertSublayer:gradient atIndex:0];

举报

相关推荐

0 条评论