Skip to content
This repository was archived by the owner on Oct 18, 2024. It is now read-only.

Repository files navigation

Deprecation

This library is deprecated in favor of iOS 12CAGradientLayer layer type .conic

See ConicSample project for CAGradientLayer examples ported from AngleGradientLayer.

standwithukrainecocoapods

AngleGradientLayer

AngleGradientLayer is a CALayer implementation of angle gradient.

screenshot

Installing

pod'AngleGradientLayer','~> 1.0'

[Swift] Using in your code

import AngleGradientLayer
classMyView:UIView{overrideclassfunc layerClass()->AnyClass{returnAngleGradientLayer.self
}overrideinit(frame:CGRect){
super.init(frame: frame)letl:AngleGradientLayer=self.layer as!AngleGradientLayer
l.colors =[UIColor(red:0, green:0, blue:0.5, alpha:1).CGColor,UIColor(red:1, green:1, blue:0.4, alpha:1).CGColor]}}

[Objective-C] Using in your code

(See demo project for more.)

#import"AngleGradientLayer.h"@interfaceMyView : UIView@end@implementationMyView
+ (Class)layerClass
{
return [AngleGradientLayer class];
}
- (id)initWithFrame:(CGRect)frame
{
if (!(self = [superinitWithFrame:frame]))
returnnil;
AngleGradientLayer *l = (AngleGradientLayer *)self.layer;
l.colors = [NSArrayarrayWithObjects:
(id)[UIColor colorWithRed:0green:0blue:0.5alpha:1].CGColor,
(id)[UIColor colorWithRed:1green:1blue:0.4alpha:1].CGColor,
nil];
return self;
}
@end

Notes

When working with semi-transparent views, be sure to set backgroundColor property on the layer's view

myview.backgroundColor =UIColor.clearColor()

backgroundColor by default is nil, blending to black color.

About

Angle gradients for iOS

Topics

Resources

Stars

247 stars

Watchers

1 watching

Forks

Contributors

Languages