cagradientlayer

Gradient in UIView inside UITableViewCell changed after scroll

六月ゝ 毕业季﹏ 提交于 2019-12-11 15:49:14
问题 I have set a gradient color to UIView inside my UITableViewCell . Everything works fine in the first load but after scroll, the gradient color is loaded again and change the position every time than the actual set condition. Here's my code for implementing gradient color : what should I do? Add Gradient Layer func gradient(frame:CGRect,colors: [CGColor]) -> CAGradientLayer { let layer = CAGradientLayer() layer.frame = frame layer.startPoint = CGPoint(x: 1.0, y: 0.0) layer.endPoint = CGPoint(x

iOS - How to apply gradient color to UICollectionViewCell backgroundView?

こ雲淡風輕ζ 提交于 2019-12-11 02:56:08
问题 I have been able to apply the gradient I want to the backgroundView of my UICollectionViewCell. But every time I reload the cell, it applies again my gradient, accumulating all the gradient. First of all here is my method for the gradient : static func setGradientWhite(uiView: UIView) { let colorBottomWhite = UIColor(red:1.00, green:1.00, blue:1.00, alpha:0.30).cgColor let colorTopWhite = UIColor(red:1.00, green:1.00, blue:1.00, alpha:0).cgColor let gradientLayer = CAGradientLayer()

Circular CAGradientLayer Mask - iOS

百般思念 提交于 2019-12-09 13:54:32
问题 I'm using CAGradientLayer on my image. I use this code to do this: UIImage *image = [UIImage imageNamed:@"perfect.jpg"]; [testImage setImage:image]; CAGradientLayer *myLayer = [CAGradientLayer layer]; myLayer.anchorPoint = CGPointZero; //starts in bottom left myLayer.startPoint = CGPointMake(1.0f,1.0f); //ends in top right myLayer.endPoint = CGPointMake(1.0f, 0.0f); UIColor *outerColor = [UIColor colorWithWhite:1.0 alpha:0.0]; UIColor *innerColor = [UIColor colorWithWhite:1.0 alpha:1.0]; //an

How to set multiple gradient colour in UITableViewCell using CAGradientLayer in iOS?

橙三吉。 提交于 2019-12-08 11:18:28
I want to set multiple gradient colour and each row would have unique gradient colour as shown image below: I want to achieve is first image & what I was able to achieve is second Code I wrote for what I was able to achieve is BackgroundLayer.h +(CAGradientLayer*) CustomHorBlack; BackgroundLayer.m + (CAGradientLayer*) CustomHorBlack { UIColor *colorOne = [UIColor colorWithRed:(0.0) green:(0.0 ) blue:(0.0) alpha:0.1]; UIColor *colorTwo = [UIColor colorWithRed:(0.0) green:(0.0 ) blue:(0.0) alpha:0.2]; UIColor *colorThree = [UIColor colorWithRed:(0.0) green:(0.0 ) blue:(0.0) alpha:0.3]; UIColor

How to add a CAGradientLayer to a UIView when using programmatic constraints

戏子无情 提交于 2019-12-08 07:16:42
问题 For an iOS app in Swift, I am using programmatic constraints and would like to add a CAGradientLayer() to a UIView(). Below is my code which doesn't work. import UIKit class ViewController: UIViewController { let animationView: UIView = { let view = UIView() view.translatesAutoresizingMaskIntoConstraints = false return view }() override func viewDidLoad() { super.viewDidLoad() view.addSubview(animationView) setupAnimationView() animationView.addGradientLayer() } func setupAnimationView() {

How to set multiple gradient colour in UITableViewCell using CAGradientLayer in iOS?

走远了吗. 提交于 2019-12-08 04:43:19
问题 I want to set multiple gradient colour and each row would have unique gradient colour as shown image below: I want to achieve is first image & what I was able to achieve is second Code I wrote for what I was able to achieve is BackgroundLayer.h +(CAGradientLayer*) CustomHorBlack; BackgroundLayer.m + (CAGradientLayer*) CustomHorBlack { UIColor *colorOne = [UIColor colorWithRed:(0.0) green:(0.0 ) blue:(0.0) alpha:0.1]; UIColor *colorTwo = [UIColor colorWithRed:(0.0) green:(0.0 ) blue:(0.0)

How to set gradient color to the background of UILabel in iPhone

随声附和 提交于 2019-12-08 02:34:30
问题 I am using the following code to set the gradient color to the background of label but no effect what i am doing wrong? Code is here: [self.teamName setTextColor:[UIColor whiteColor]]; [self.teamName setBackgroundColor:[UIColor clearColor]]; CAGradientLayer *gradientLayer = [CAGradientLayer layer]; gradientLayer.frame = self.teamName.bounds; gradientLayer.colors = [NSArray arrayWithObjects:(id)[[UIColor whiteColor]CGColor], (id)[[UIColor blackColor]CGColor], nil]; [self.teamName.layer

Adding gradient layer to tableview

丶灬走出姿态 提交于 2019-12-07 23:57:51
问题 I have been trying to figure out for quite a while now about how to add a gradient layer to the tableView, and have tried many different things, but I can never get the table view cells to show, no matter how many bringSubviews or sendSubviews I do. let gradientLayer = CAGradientLayer() gradientLayer.frame = view.bounds gradientLayer.colors = [UIColor(red: 125/255.0, green: 125/255.0, blue: 125/255.0, alpha: 1.0).cgColor, UIColor(red: 125/255.0, green: 125/255.0, blue: 255/255.0, alpha: 1.0)

UIView layer's sublayers display differently/randomly each time view appears

余生颓废 提交于 2019-12-07 17:15:26
I have a simple custom CALayer to create an overlaying gradient effect on my UIView. Here is the code: class GradientLayer: CALayer { var locations: [CGFloat]? var origin: CGPoint? var radius: CGFloat? var color: CGColor? convenience init(view: UIView, locations: [CGFloat]?, origin: CGPoint?, radius: CGFloat?, color: UIColor?) { self.init() self.locations = locations self.origin = origin self.radius = radius self.color = color?.CGColor self.frame = view.bounds } override func drawInContext(ctx: CGContext) { super.drawInContext(ctx) guard let locations = self.locations else { return } guard let

CAGradientLayer not working [duplicate]

夙愿已清 提交于 2019-12-06 21:38:32
问题 This question already has an answer here : Drawing gradient on UIView not working with iOS 9 (1 answer) Closed 4 years ago . I created a new project. I linked QuartzCore.framework and imported <QuartzCore/QuartzCore.h> in the ViewController.m . And here is the code. - (void)viewDidLoad { [super viewDidLoad]; NSLog(@"view height %f", self.view.frame.size.height); // returns 667 on iPhone 6 NSLog(@"view width %f", self.view.frame.size.width); // returns 375 on iPhone 6 NSLog(@"layers count %lu"