cagradientlayer

Adding gradient layer to tableview

送分小仙女□ 提交于 2019-12-06 05:20:24
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).cgColor] gradientLayer.startPoint = CGPoint(x: 0.0, y: 0.0) gradientLayer.endPoint = CGPoint(x: 0.0, y:

Why gradient layer in UITableViewCell not cover entire frame?

蓝咒 提交于 2019-12-05 12:54:39
I try to make a standard gradient top-bottom with long UIView. But it's not full. The nib is part of UITableViewCell, so I don't have access to viewDidLayoutSubviews() as in this thread . I've tried to call contentView.layoutIfNeeded() from the code version of this view. I called it when UITableView cellForRowAtIndexPath gets called. But it's no effect. I prepare the gradient in awakeFromNib() . let colors = [ UIColor(red: 33/255.0, green: 33/255.0, blue: 33/255.0, alpha: 1.0).cgColor, UIColor(red: 51/255.0, green: 51/255.0, blue: 51/255.0, alpha: 1.0).cgColor] let gradient = CAGradientLayer()

CAGradientLayer not working [duplicate]

喜欢而已 提交于 2019-12-05 03:44:31
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", self.view.layer.sublayers.count); // returns 2 // Gradient UIColor *colorOne = [UIColor blueColor];

Angled Gradient Layer

╄→尐↘猪︶ㄣ 提交于 2019-12-04 23:28:40
问题 I have custom UIView class that renders a gradient in Swift 2. I'm struggling with making an angled gradient so that it draws from the top-left to the bottom-right. Can somebody help me a bit? import UIKit class GradientView: UIView { let gradientLayer = CAGradientLayer() override func awakeFromNib() { // 1 self.backgroundColor = ColorPalette.White // 2 gradientLayer.frame = self.bounds // 3 let color1 = ColorPalette.GrdTop.CGColor as CGColorRef let color2 = ColorPalette.GrdBottom.CGColor as

Button background and gradient change since iOS6

浪尽此生 提交于 2019-12-04 21:02:10
问题 For an app I had to create a UIButton filled with a gradient and a background image. Everything worked fine until I upgraded the OS from iOS 5.1 to the recently released iOS 6. Here are two screenshots from the simulator : Well, the first screenshot shows what I need (and did), you can see a brown background and the grey radient. Below is the screenshot with the same buttons but with iOS 6 running. As you can see the gradient has vanished and a strange white strip has appeared at the bottom

Objective C - CAGradientLayer covers the text in UILabel?

和自甴很熟 提交于 2019-12-04 17:32:33
问题 I am trying to add a gradient layet to my UILabel for some reasons the CAGradientLayer covers my text. Am I doing anything wrong - (void)viewDidLoad { [super viewDidLoad]; CAGradientLayer *gradient = [CAGradientLayer layer]; gradient.frame = CGRectMake(0, 0, myLabel.frame.size.width, myLabel.frame.size.height); gradient.colors = myColors; [myLabel.layer insertSublayer:gradient atIndex:0]; } 回答1: The CAGradientLayer is covering the text of your label because the text is drawn by the content of

How to draw Arc with curved edge in iOS?

南笙酒味 提交于 2019-12-04 14:01:42
In one of my application, I am trying to draw a gradient arc with rounded edges. Like the following image. This is what I have done so far using the following code. -(void)startArc { UIBezierPath *roundedArc = [self arcWithRoundedCornerAt:centerPoint startAngle:DEGREES_TO_RADIANS(-90) endAngle:DEGREES_TO_RADIANS(90) innerRadius:width-20 outerRadius:width cornerRadius:0]; CAShapeLayer *mask = [CAShapeLayer new]; [mask setPath:roundedArc.CGPath]; [mask setFrame:_outerView.bounds]; [mask setShouldRasterize:YES]; [mask setRasterizationScale:[UIScreen mainScreen].scale]; CAGradientLayer *gradient =

Filling a path with a gradient on iOS

◇◆丶佛笑我妖孽 提交于 2019-12-04 11:00:38
问题 On a CAShapeLayer , I've drawn a closed UIBezierPath . I can fill this shape by setting the fillColor , however I want to fill the shape with a gradient. How can I set up the CAGradientLayer so it clips to the shape outlined by the bezier path? 回答1: What you want is a mask. CAGradientlayer has a -setMask method that can clip it to the bounds of your shape like so: [gradientLayer setMask:shapeLayer]; 回答2: A draft example would be the following: ... CGColorSpaceRef colorSpace =

How to draw a gradient color wheel using CAGradientLayer?

柔情痞子 提交于 2019-12-04 08:21:51
问题 I got some reference from these links- What is the Algorithm behind a color wheel? Math behind the Colour Wheel Basic color schemes How to fill a bezier path with gradient color I have gone through the concept of "HSV colour space". But I want to draw a color wheel using RGB with the help of CAGradientLayer . Here is the code snippet of making a color wheel by using simple RGB color array and UIBezierPath - func drawColorWheel() { context?.saveGState() range = CGFloat(100.00 / CGFloat

Gradient Animation - Slow down and speed up

此生再无相见时 提交于 2019-12-04 02:18:11
问题 I'm animating a CAGradientLayer , similar to how Apple did with their "Slide to Unlock" animation on the home screen of iPhone. However my animation is a little different in that it slows down and speeds up at certain points. The code I have so far is animates a gradient and works, but how would I get it to slow down/speed up at different points? class AnimatedMaskLabel: UIView { let gradientLayer: CAGradientLayer = { let gradientLayer = CAGradientLayer() // Configure the gradient here