zoukankan      html  css  js  c++  java
  • 渐变色

     1 - (void)setupDurationLabelBgView
     2 {
     3     CGFloat bgimageViewWidth = 165 * kBigScreenViewWidthRate;
     4     CGFloat bgimageViewHeight = 20 * kBigScreenViewWidthRate;
     5 
     6     UIView *durationLabelBgView = [[UIView alloc] init];
     7     [_imgView addSubview:durationLabelBgView];
     8     [durationLabelBgView mas_makeConstraints:^(MASConstraintMaker *make) {
     9         make.left.right.bottom.mas_equalTo(_imgView);
    10         make.height.mas_equalTo(bgimageViewHeight);
    11     }];
    12     UIColor *color1 = UIColorFromHexWithAlpha(0x000000, 0);
    13     UIColor *color2 = UIColorFromHexWithAlpha(0x000000, 1);
    14     CAGradientLayer *commonLayer = [self gradientLayerWithColor1:color1 color2:color2];
    15     commonLayer.frame = CGRectMake(0, 0, bgimageViewWidth, bgimageViewHeight);
    16     [durationLabelBgView.layer addSublayer:commonLayer];
    17 }
    18 
    19 - (CAGradientLayer *)gradientLayerWithColor1:(UIColor *)color1 color2:(UIColor *)color2{
    20     //初始化CAGradientlayer对象,使它的大小为UIView的大小
    21     CAGradientLayer *gradientLayer = [CAGradientLayer layer];
    22     
    23     //设置渐变区域的起始和终止位置(范围为0-1)
    24     gradientLayer.startPoint = CGPointMake(0, 0);
    25     gradientLayer.endPoint = CGPointMake(1, 0);
    26     
    27     gradientLayer.colors = @[(__bridge id)color1.CGColor,
    28                              (__bridge id)color2.CGColor];
    29     //设置颜色分割点(范围:0-1)
    30     gradientLayer.locations = @[@(0.0f), @(0.6)];
    31     
    32     return gradientLayer;
    33 }
  • 相关阅读:
    HDU_2203_KMP入门
    HDU_1711_初识KMP算法
    过滤器基础
    HDU_1907_基础博弈nim游戏
    nim游戏解法(转)
    HDU_1517_博弈(巧妙规律)
    HDU_1850_nim游戏
    HDU_1847_基础博弈sg函数
    < 转>Java 反射机制浅析
    <转>单机版搭建Hadoop环境
  • 原文地址:https://www.cnblogs.com/lz465350/p/7735991.html
Copyright © 2011-2022 走看看