CAGradientLayer(FWLayer)

@interface CAGradientLayer (FWLayer)

/**
 *  创建渐变层,需手工addLayer
 *
 *  @param frame      渐变区域
 *  @param colors     渐变颜色,CGColor数组,如[黑,白,黑]
 *  @param locations  渐变位置,0~1,如[0.25, 0.5, 0.75]对应颜色为[0-0.25黑,0.25-0.5黑渐变白,0.5-0.75白渐变黑,0.75-1黑]
 *  @param startPoint 渐变开始点,设置渐变方向,左上点为(0,0),右下点为(1,1)
 *  @param endPoint   渐变结束点
 *  @return 渐变Layer
 */
+ (CAGradientLayer *)fw_gradientLayer:(CGRect)frame
                              colors:(NSArray *)colors
                           locations:(nullable NSArray<NSNumber *> *)locations
                          startPoint:(CGPoint)startPoint
                            endPoint:(CGPoint)endPoint NS_REFINED_FOR_SWIFT;

@end

Undocumented

  • 创建渐变层,需手工addLayer

    Declaration

    Objective-C

    + (nonnull CAGradientLayer *)
        fw_gradientLayer:(CGRect)frame
                  colors:(nonnull NSArray *)colors
               locations:(nullable NSArray<NSNumber *> *)locations
              startPoint:(CGPoint)startPoint
                endPoint:(CGPoint)endPoint;

    Parameters

    frame

    渐变区域

    colors

    渐变颜色,CGColor数组,如[黑,白,黑]

    locations

    渐变位置,0~1,如[0.25, 0.5, 0.75]对应颜色为[0-0.25黑,0.25-0.5黑渐变白,0.5-0.75白渐变黑,0.75-1黑]

    startPoint

    渐变开始点,设置渐变方向,左上点为(0,0),右下点为(1,1)

    endPoint

    渐变结束点

    Return Value

    渐变Layer