Questions tagged [cagradientlayer]

`CAGradientLayer` is a special purpose `CALayer` subclass for drawing animatable linear gradients. It's a part of the QuartzCore framework and is available for both iOS (since iOS 3.0) and OS X (since OS X v10.6 "Snow Leopard"). The gradient is specified using four properties for the `colors`, their `locations` and the `startPoint` and `endPoint` of the layer. All four properties are animatable.

CAGradientLayer is a special purpose CALayer subclass for drawing animatable linear gradients. It's a part of the framework and is available for both (since iOS 3.0) and (since OS X v10.6 "Snow Leopard").

The gradient is specified using four properties for the colors, their locations and the startPoint and endPoint of the layer. All four properties are animatable.

The colors is an NSArray of CGColorRef objects therefore they need to be cast to ids when adding them to the array.

The locations, startPoint and endPoint are specified in the unit coordinate space of the layers bounds. This means that the values go from 1.0 to 0.0. In both iOS and OS X, x increases to the right which means that 0.0 is the left edge and 1.0 is the right edge. On iOS y increases downward and on OS X y increases upwards.

405 questions
0
votes
1 answer

change or remove my CAGradientLayer when button is disabled

I'm using a CAGradientLayer as the background for my button. cell.showOnMap.clipsToBounds = YES; cell.showOnMap.layer.cornerRadius = 10.0f; UIView *view2 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, cell.showOnMap.frame.size.width,…
Eichhörnchen
  • 592
  • 2
  • 12
  • 27
0
votes
1 answer

Prevent CAGradientLayer from Overlapping inside UIImageView on UITableViewCell

I am applying a gradient in my custom UITableViewCell using Storyboards inside my cellForRowAtIndexPath method and I wanted to prevent my application of CAGradientLayer gradient to overlap. How can I do this? This is my current code I'm using to…
jaytrixz
  • 4,059
  • 7
  • 38
  • 57
0
votes
1 answer

Using CAGradientLayer on UITextView in UITableViewCell

I have a UITextView in a collapsable TableViewCell. In the UITextView I want a CAGradientLayer to fade out the above en bottom text. I made a UIView with the UITextView in it. This is all in the cell I don't know how to set the code, in the cell or…
SwingerDinger
  • 276
  • 1
  • 7
  • 21
0
votes
2 answers

CAGradientLayer for only background

I am setting gradient to background of my view: CAGradientLayer *grad = [CAGradientLayer layer]; grad.frame = self.contentView.frame; grad.colors = @[(id)[[UIColor colorWithRed:1.0f green:0.5f blue:0.5f alpha:0.0f] CGColor], …
Martin Perry
  • 9,232
  • 8
  • 46
  • 114
0
votes
1 answer

ios - Transparent radial Gradient Layer Mask

I'm using a CAGradientLayer to as a layer to my image. Im using this code: UIImage *image = [UIImage imageNamed:@"perfect.jpg"]; [testImage setImage:image]; CAGradientLayer *myLayer = [CAGradientLayer layer]; myLayer.anchorPoint =…
0
votes
1 answer

Issue adding CAGradientLayer sublayer to UIView

I've created a CAGradientLayer, which I'd like to add as a sublayer to a UIView. I can add it to self.view.layer with no problems, but cannot for the life of me get it to appear when added to the UIView. Here's the simplified code. -…
wanderingme
  • 745
  • 1
  • 5
  • 7
0
votes
1 answer

How to modify the view's CALayer

I see the code in MTAnimatedLabel CAGradientLayer *gradientLayer = (CAGradientLayer *)self.layer; gradientLayer.backgroundColor = [super.textColor CGColor]; gradientLayer.startPoint = CGPointMake(-self.gradientWidth,…
zedzhao
  • 517
  • 1
  • 3
  • 17
0
votes
1 answer

CAGradientLayer for different views

I would like to create a color gradient with CAGradientLayer for multiple views with different sizes. I don't know how to define the frame separately: UIColor *darkOp = [UIColor colorWithRed:0.2f green:0.2f blue:0.27f alpha:1.0]; UIColor *lightOp =…
JFS
  • 2,992
  • 3
  • 37
  • 48
0
votes
1 answer

apply CAGradient layer on UIImageView On Top edge and Left edge

Here is the code i Use to apply CAGradient layer On UIIimageView .It works on one Edge but i am not able to apply on other edges. I use two CAGradient layers To apply on left and Top of ImageView To Fade it.But It Only applied one side of…
0
votes
1 answer

layer.mask gradient is Solid in iOS7

The next code was working fine in ios6. It is supposed to apply a top and bottom inner alpha gradient to a view: CAGradientLayer * gradient = [CAGradientLayer layer]; gradient.frame = self.bounds; gradient.colors = [NSArray…
Mephes
  • 58
  • 7
0
votes
1 answer

CAGradientLayer unexpected output when masked with CAShapeLayer from UIBezierPath

I'm using this sample code from Palimondo: it is brilliant code learning how to mask CAGradientLayer's onto CAShapeLayers. The Output is as follows: Now I am trying to create this image: Using PaintCode, I was able to get all the UIBezierPath's…
Maximilian
  • 1,107
  • 11
  • 20
0
votes
1 answer

CAGradientLayer SetMask on CAShapeLayer crashes app

Using example code from many great people, I am able to make a complex shape using CAShapeLayer and present that no problem using a subclassed UIView: @implementation BMTestLogo + (Class)layerClass { return [CAShapeLayer class]; } -…
Maximilian
  • 1,107
  • 11
  • 20
0
votes
2 answers

Gradient Color to Custom View

I have created 3 custom views in a UIViewController. In each custom view, I have created shapes using CAShapeLayer. These layers also contain gradient colour. Now I want to set gradient colour to custom views. When I am trying to do that, it is…
user007
  • 69
  • 8
0
votes
2 answers

Adding Gradientlayer in cellForRowAtIndexPath

I have a tableview of custom cells. In each cell, I m adding an label as a subview and loading data in the label.I m adding gradient in my cellForRowAtIndexPath for each cell inside if block where we check whether the cell is nil or not. Its working…
nOOb iOS
  • 1,384
  • 2
  • 19
  • 37
0
votes
1 answer

CAGradientLayer giving EXC_BAD_ACCESS?

I'm trying to make the ends of my UIScrollView fade out - just like one would a UITableView. I found the below code. I'm using it in a UIScrollView subclass in a method called inside initWithFrame:.... if (!maskLayer) { maskLayer =…
Undo
  • 25,519
  • 37
  • 106
  • 129