1.设置渐变色
#pragma mark - 渐变色设置
- (void)configGraduallyColor {
//CAGradientLayer是CALayer的一个特殊子类,用于生成颜色渐变的图层
CAGradientLayer *gradientLayer = [CAGradientLayer layer];
//colors 渐变的颜色
gradientLayer.colors = @[(__bridge id)[UIColor greenColor].CGColor, (__bridge id)[UIColor yellowColor].CGColor, (__bridge id)[UIColor purpleColor].CGColor];
//locations 渐变颜色的分割点
gradientLayer.locations = @[@0.3, @0.5, @1.0];
//startPoint&endPoint 颜色渐变的方向,范围在(0,0)与(1.0,1.0)之间,如(0,0)(1.0,0)代表水平方向渐变,(0,0)(0,1.0)代表竖直方向渐变
gradientLayer.startPoint = CGPointMake(0, 0);
gradientLayer.endPoint = CGPointMake(1.0, 0);
gradientLayer.frame = CGRectMake(50, 100, 300, 100);
[self.view.layer addSublayer:gradientLayer];
}
2.ATS
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>