酷店

UIView+Gradient.h 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. //
  2. // UIView+Gradient.h
  3. // AZCategory
  4. //
  5. // Created by Alfred Zhang on 2017/6/29.
  6. // Copyright © 2017年 Alfred Zhang. All rights reserved.
  7. //
  8. #import <UIKit/UIKit.h>
  9. @interface UIView (Gradient)
  10. /* The array of CGColorRef objects defining the color of each gradient
  11. * stop. Defaults to nil. Animatable. */
  12. @property(nullable, copy) NSArray *colors;
  13. /* An optional array of NSNumber objects defining the location of each
  14. * gradient stop as a value in the range [0,1]. The values must be
  15. * monotonically increasing. If a nil array is given, the stops are
  16. * assumed to spread uniformly across the [0,1] range. When rendered,
  17. * the colors are mapped to the output colorspace before being
  18. * interpolated. Defaults to nil. Animatable. */
  19. @property(nullable, copy) NSArray<NSNumber *> *locations;
  20. /* The start and end points of the gradient when drawn into the layer's
  21. * coordinate space. The start point corresponds to the first gradient
  22. * stop, the end point to the last gradient stop. Both points are
  23. * defined in a unit coordinate space that is then mapped to the
  24. * layer's bounds rectangle when drawn. (I.e. [0,0] is the bottom-left
  25. * corner of the layer, [1,1] is the top-right corner.) The default values
  26. * are [.5,0] and [.5,1] respectively. Both are animatable. */
  27. @property CGPoint startPoint;
  28. @property CGPoint endPoint;
  29. + (UIView *_Nullable)gradientViewWithColors:(NSArray<UIColor *> *_Nullable)colors locations:(NSArray<NSNumber *> *_Nullable)locations startPoint:(CGPoint)startPoint endPoint:(CGPoint)endPoint;
  30. - (void)setGradientBackgroundWithColors:(NSArray<UIColor *> *_Nullable)colors locations:(NSArray<NSNumber *> *_Nullable)locations startPoint:(CGPoint)startPoint endPoint:(CGPoint)endPoint;
  31. @end