cagradientlayer

Circular CAGradientLayer Mask - iOS

自闭症网瘾萝莉.ら 提交于 2019-12-03 21:44:03
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 array of colors that dictatates the gradient(s) myLayer.colors = @[(id)outerColor.CGColor, (id

Button background and gradient change since iOS6

别等时光非礼了梦想. 提交于 2019-12-03 14:39:44
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 of the UIButton . I've looked if this is a bug or something but I've found nothing, maybe someone here

UIButton with GradientLayer obscures image and darkens gradient

拥有回忆 提交于 2019-12-03 08:14:35
问题 I have an UIButton here where I'd like to have a gradient as the background below the image (symbol with transparent background), but I'm facing two different problems. First of the CAGradientLayer seems to overlay on top of the image no matter how I try to add it, obscuring the image completely. Secondly the gradient itself seems to be darkened a lot, like the button was disabled, which it isn't. Here's my code: self.backButton = [[UIButton alloc] initWithFrame:CGRectMake(15, 35, 28, 28)];

iOS White to Transparent Gradient Layer is Gray

岁酱吖の 提交于 2019-12-03 07:20:36
问题 I have a CAGradientLayer inserted to the bottom of this small detail view that pops up at the bottom of the app. As you can see, I've set the colors from white to clear, but there's this strange gray tint that is showing up. Any ideas? // Set up detail view frame and gradient [self.detailView setFrame:CGRectMake(0, 568, 320, 55)]; CAGradientLayer *layer = [CAGradientLayer layer]; layer.frame = self.detailView.bounds; layer.colors = [NSArray arrayWithObjects:(id)[UIColor whiteColor].CGColor,

iOS White to Transparent Gradient Layer is Gray

帅比萌擦擦* 提交于 2019-12-02 19:53:38
I have a CAGradientLayer inserted to the bottom of this small detail view that pops up at the bottom of the app. As you can see, I've set the colors from white to clear, but there's this strange gray tint that is showing up. Any ideas? // Set up detail view frame and gradient [self.detailView setFrame:CGRectMake(0, 568, 320, 55)]; CAGradientLayer *layer = [CAGradientLayer layer]; layer.frame = self.detailView.bounds; layer.colors = [NSArray arrayWithObjects:(id)[UIColor whiteColor].CGColor, (id)[UIColor clearColor].CGColor, nil]; layer.startPoint = CGPointMake(1.0f, 0.7f); layer.endPoint =

Subviews are not displaying for CAGradientLayer added view [duplicate]

三世轮回 提交于 2019-12-02 13:28:28
This question already has an answer here: How to Apply Gradient to background view of iOS Swift App 25 answers 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 ,colorEnd:CGColor,cornerRadius:CGFloat) { let gradientLayer = CAGradientLayer() gradientLayer.colors = [colorStart, colorEnd] gradientLayer.startPoint = CGPoint(x: 0.0, y: 0.5); gradientLayer.endPoint = CGPoint(x: 1.0, y: 0.5); gradientLayer

iOS UISLider with gradient layer

你说的曾经没有我的故事 提交于 2019-12-02 10:59:26
问题 I'm building an iOS application in which I have to implement a custom UISlider. The problem is that the built-in UISlider doesn't support gradient track. Another issue is my UI style guide shows that the current tracking value rectangle should be a gradient of two colors as shown in the image How can I build a customized version of the UISlider? I have thought of either subclassing the existing one or by building a UIControl subclass. I'm using xcode 9.4 and swift 4.2 Thanks in advance! 回答1:

Swift: gradient on a cell of a tableview

丶灬走出姿态 提交于 2019-12-02 10:25:13
On tableView's cells, I'm trying to define a gradient with the following Swift code: func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! { var cell:UITableViewCell = self.tableView?.dequeueReusableCellWithIdentifier("cell") as UITableViewCell cell.backgroundColor=UIColor.clearColor() let gradient : CAGradientLayer = CAGradientLayer() var arrayColors:Array<AnyObject> = [UIColor.blackColor().CGColor, UIColor.whiteColor().CGColor] gradient.colors=arrayColors gradient.frame = cell.bounds cell.layer.insertSublayer(gradient, atIndex: UInt32

iOS UISLider with gradient layer

北战南征 提交于 2019-12-02 06:23:30
I'm building an iOS application in which I have to implement a custom UISlider. The problem is that the built-in UISlider doesn't support gradient track. Another issue is my UI style guide shows that the current tracking value rectangle should be a gradient of two colors as shown in the image How can I build a customized version of the UISlider? I have thought of either subclassing the existing one or by building a UIControl subclass. I'm using xcode 9.4 and swift 4.2 Thanks in advance! I ended up solving the problem by setting the gradient layer as an image for the slider minimum track image

How can I add a gradient that spans two views?

喜你入骨 提交于 2019-12-02 01:52:55
I know how to do (1) but how can I do (2)? UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 50)]; CAGradientLayer *gradient = [CAGradientLayer layer]; gradient.frame = view.bounds; gradient.colors = @[(id)[UIColor blueColor].CGColor, (id)[UIColor redColor].CGColor]; [view.layer insertSublayer:gradient atIndex:0]; There are several ways you could do this. Here's one way: Create a UIView subclass named GradientView to manage the gradient layer. This is helpful because it means you can use the normal UIKit techniques to manage the gradient layout (auto layout constraints,