IOS: CALayer, ioscalayer
Directory
1. CALayer (parent class)
2. CAShapeLayer (shape/canvas)
3. CAGradientLayer (gradient layer)
Order: contact/learning order
1. CALayer (parent class)
1-1). Several common attributes
2. CAShapeLayer
2-1) for usage, refer to iOS: Drawing> "1. UIBezierPath (bessercurve)"> "1-2 ),".
3. CAGradientLayer (gradient layer)
3-1). Transparency (example)
// Create CAGradientLayer * gradientLayer = [CAGradientLayer layer]; // gradient point UIColor * colorTop = [[UIColor alloc] initWithRed: 0.0 green: 0.0 blue: 0.0 alpha: 1]; UIColor * colorButtom = [[UIColor alloc] initWithRed: 0.0 green: 0.0 blue: 0.0 alpha: 0]; gradientLayer. colors = @ [(_ bridge id) colorTop. CGColor, (_ bridge id) colorButtom. CGColor]; // gradient point position (the number corresponds to the number of colors. It's okay if there is no correspondence, but it's a bit strange). The smaller the distance between the point and the point, the faster the change. // gradientLayer. location S = @ [@ 0.0, @ 1.0]; // change type, linear change (only this macro is available, and it's okay if it's not set) // gradientLayer. type = kCAGradientLayerAxial; // Gradient Direction x: 0-> 1 left to right, and vice versa. Similarly, y: 0-> 1 to bottom, and vice versa. (0.0)-> (1.1) gradientLayer is changed from top left to bottom right of the screen. startPoint = CGPointMake (0, 0); gradientLayer. endPoint = CGPointMake (0, 1.0); // The size. If it is smaller than bounds, you must set the position. GradientLayer. frame = self. bounds; // Add [self. layer addSublayer: gradientLayer];