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
-1
votes
1 answer

Programmatically create a UIView with color gradient with blur effect in ios

I am tying to create a UIview with color gradient and blur effect(360 Degree) using objective c. I can did this gradient effect only one direction. I need the output like rectangle one with 360 degree. Here is my code CAGradientLayer *gradient…
Silambarasan
  • 767
  • 5
  • 19
-1
votes
1 answer

How to add gradient layer which fills the view frame exactly

In my app i'm adding the gradient layer to UIView and UIToolBar but it doesn't fill the views exactly let gradient:CAGradientLayer = CAGradientLayer() gradient.frame = self.vw_gradientForToolBar.bounds gradient.colors …
Kalikanth040494
  • 452
  • 5
  • 15
-1
votes
1 answer

How to check and set grediant view in swift?

I want to set gradient color to background on button click following is my code, i am getting crash on for case let objGrediantView as CAGradientLayer() in sender.subviews To check is there Grediant or not func setGrediantView(sender: AnyObject,…
-1
votes
1 answer

How come my CAGradientLayer is not displaying?

I need to know what i am doing wrong. Im literally copying and pasting this into my code and the gradient is not displaying. #import "ViewController.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad { …
Esko918
  • 1,397
  • 1
  • 12
  • 25
-1
votes
2 answers

How to continually change gradient color background?

I currently have a single gradient color background (see below), but I want to gradually change the colors to shades that I will pre-define in an array and have it loop through. How can I achieve this? var colorTop = UIColor(red: 255.0/255.0,…
-1
votes
1 answer

How do I add a label on top of a gradient?

I have a very basic UICollectionView. Inside my CollectionViewCell, I have a "thumbnailImage" which is just an image. I would like to have a gradient layer that fades from black, to a clear color BUT I would also like to have a UILabel ON TOP of…
Daniel Dramond
  • 1,538
  • 2
  • 15
  • 26
-1
votes
1 answer

Making Gradient Background in Swift - The Right Way

This is my code for a gradient background. When I apply it on my view, it hides all my stuff on that VC, like it's on the front and everything else is pushed back. How can I make a gradient view that is not interfering with my elements? I'm using…
Kira
  • 1,575
  • 4
  • 26
  • 48
-1
votes
1 answer

Added CAGradientLayer, getting this in my UIView dealloc: [CALayer release]: message sent to deallocated instance

Here there, I have a custom UIView. This view acts as a activity indicator but as label above the UIActivityIndicatorView. In the init, I add a CAGradientLayer. I allocate and initialize it and insert it at index 0 as a sublayer of the UIView layer…
user619891
-2
votes
2 answers

Create a custom step indicator in iOS with Swift

How do I create a progress indicator as shown in swift for iOS? Tried various libraries. But nothing fits exactly.The color should be in gradient and the current state must show the step number.
Anup G Prasad
  • 246
  • 2
  • 4
  • 14
-2
votes
1 answer

Can I change CAGradientLayer() colors via an IBAction?

I have the following extension file defined where I am setting a gradient for my UIView: import Foundation import UIKit extension UIView { func setGradientBackground(colorOne: UIColor, colorTwo: UIColor) { let gradientLayer =…
chuckbass
  • 95
  • 7
-2
votes
2 answers

Subviews are not displaying for CAGradientLayer added view

used below code for adding gradient layer for a view. After adding gradient layer to a view if i tried to add new subviews inside my gradient view the new view are not getting displayed func setGradientBackground(_ view: UIView ,colorStart:CGColor…
Midhun Narayan
  • 829
  • 2
  • 9
  • 26
-2
votes
1 answer

Animate view's subViews is not working with CAGradientLayer

I would like to use CAGradientLayer in my app. I'm inserting a CAGradientLayer at index 0 of the viewController's view's sublayers: class ViewController: UIViewController { var label: UILabel! override func viewDidLoad() { let width =…
Mion Kovalski
  • 19
  • 1
  • 7
-2
votes
1 answer

CAGradientLayer Locations in Swift

I know that the swift array bridges to NSarray. Swift array can only contain one type. I want to set the locations for CAGradientLayer in swift. I need to nil terminate the array. Are the only options: A.) create an NSArray object with floats and…
ImpactZero
  • 547
  • 4
  • 8
-3
votes
2 answers

How to add a gradient to a view in iOS?

I am learning about the basics of Swift and iOS App Development. I want to create a gradient page in my application. I found this code online: let gradient = CAGradientLayer() // Line 1 gradient.frame = view.bounds // Line 2 gradient.colors =…
-3
votes
3 answers

How to set black transparent for UILabel?

I would like to set a transparent black background colour for a UILabel. CAGradientLayer *gradient = [CAGradientLayer layer]; gradient.frame = label.frame; [label.layer addSublayer:gradient]; Can I use a gradient to achieve this? Or should I use…
Kishore Kumar
  • 4,265
  • 3
  • 26
  • 47
1 2 3
26
27