zoukankan      html  css  js  c++  java
  • gradient color

    http://www.cnblogs.com/YouXianMing/p/3793913.html


    layer 不能自动autolay, 只能在viewDidLayout里面设置宽度

    - (void) viewDidLayoutSubviews {
      [super viewDidLayoutSubviews]; //if you want superclass's behaviour... 
      // resize your layers based on the view's new frame
      self.editViewBorderLayer.frame = self.editView.bounds;
    }
    

      

    gradientLayer = [CAGradientLayer layer];
    _gradientLayer.frame = maskedImageView.bounds;
    _gradientLayer.colors = colors;
    
    //set locations for the colors
    NSArray * startingLocations = @[@0.0, @0.4,@1.0];
    NSArray *endinglocations = @[@0.0,@0.8,@1.0];
    
    // Update the model layer to the final point
    _gradientLayer.locations = endinglocations;
    _gradientLayer.startPoint = CGPointMake(0.0f, 0.3f);
    _gradientLayer.endPoint = CGPointMake(1.0f, 0.5f);
    
    //add the text image as a mask on the gradient layer
    _gradientLayer.mask = maskedImageView.layer;
    
    //add the gradient layer to the holder view
    [_slideImageView.layer addSublayer:_gradientLayer];
    

      

    location 代表的是分界线, 比如三个的话就为 @[@(0), @(5), @(1)]


    https://github.com/yannickl/DynamicColor


    208
    down vote
    accepted
    - (UIColor *)lighterColorForColor:(UIColor *)c
    {
        CGFloat r, g, b, a;
        if ([c getRed:&r green:&g blue:&b alpha:&a])
            return [UIColor colorWithRed:MIN(r + 0.2, 1.0)
                                   green:MIN(g + 0.2, 1.0)
                                    blue:MIN(b + 0.2, 1.0)
                                   alpha:a];
        return nil;
    }
    
    - (UIColor *)darkerColorForColor:(UIColor *)c
    {
        CGFloat r, g, b, a;
        if ([c getRed:&r green:&g blue:&b alpha:&a])
            return [UIColor colorWithRed:MAX(r - 0.2, 0.0)
                                   green:MAX(g - 0.2, 0.0)
                                    blue:MAX(b - 0.2, 0.0)
                                   alpha:a];
        return nil;
    }
    http://stackoverflow.com/questions/11598043/get-slightly-lighter-and-darker-color-from-uicolor
    
    @implementation UIColor (LightAndDark)
    
    - (UIColor *)lighterColor
    {
        CGFloat h, s, b, a;
        if ([self getHue:&h saturation:&s brightness:&b alpha:&a])
            return [UIColor colorWithHue:h
                              saturation:s
                              brightness:MIN(b * 1.3, 1.0)
                                   alpha:a];
        return nil;
    }
    
    - (UIColor *)darkerColor
    {
        CGFloat h, s, b, a;
        if ([self getHue:&h saturation:&s brightness:&b alpha:&a])
            return [UIColor colorWithHue:h
                              saturation:s
                              brightness:b * 0.75
                                   alpha:a];
        return nil;
    }
    @end
    

      


    CGFloat red, green, blue, alpha;
    
    //Create a sample color
    
    UIColor *redColor = [UIColor redColor];
    
    //Call 
    
    [redColor getRed: &red 
      green: &green
      blue: &blue 
      alpha: &alpha];
    NSLog(@"red = %f. Green = %f. Blue = %f. Alpha = %f",
      red,
      green,
      blue,
  • 相关阅读:
    MyEclipse 快捷键(转载)
    Microsoft .NET Framework 2.0安装失败
    数据库管理方面的电子书下载地址汇总
    增强MyEclipse的代码自动提示功能 (转载)
    有关Eclipse的自动完成&代码整理(摘)
    使用NewtonSoft.JSON.dll来序列化和发序列化对象(转载)
    hMailServer配置默认域名
    arcgis中的 style和serverstyle(转载)
    python function learning
    整理的设计模式博文列表
  • 原文地址:https://www.cnblogs.com/studyNT/p/5251258.html
Copyright © 2011-2022 走看看