cagradientlayer

Making a gradient arc?

*爱你&永不变心* 提交于 2019-11-28 13:13:47
i wanna make an arc with the use of CAGradientLayer in such a way:- 20% of the arc have same single color then other 80% of arc has a gradient of two colors. I already tried by hand on locations startPoint endPoint property of CAGradientLayer but couldn't get the success and already go through from tutorials but somehow couldn't understand the concept properly.please solve my problem with clear description of it. // for beizier path - (UIBezierPath *)samplePath { UIBezierPath *path = [UIBezierPath bezierPath]; path = [UIBezierPath bezierPath]; [path addArcWithCenter:CGPointMake(200, 200)

How to have a Gradient Layer's size placed behind a UITextField, match the UITextField size, after re-sizing the layout?

佐手、 提交于 2019-11-28 02:10:40
问题 What you will see in the first image, if you scroll down a little bit, is the initial screen of a fin app. Basically, every section you see on the screen is placed within a vertical Stack View. Then every Label and Cell Is placed in a horizontal Stack View and so on, so the app auto-resizes for any screen size. I was using Story Board to create the elements. The last section has two blue UITextFields that have a gradient layer behind it. I created an extension UITextField Class in a separate

Fade out scrolling UITextView over image?

不问归期 提交于 2019-11-27 19:47:26
I’m looking to fade out a scrolling UITextView over a background image, something similar to the gradient at the top of this little example. I’m trying to work out how I can achieve this using CAGradientLayer and masks. As the text in the view scrolls (vertically), I need the text to become transparent before it hits the frame of the view, to give the illusion that it’s fading out upward and downward. Any tips on how I might achieve this? Oh man, I use this a lot. Have it saved as a snippet: CAGradientLayer *gradient = [CAGradientLayer layer]; gradient.frame = self.textView.superview.bounds;

How to apply CAGradientLayer as mask of another CALayer?

怎甘沉沦 提交于 2019-11-27 15:44:22
问题 I have a view, which has a CALayer. When I create a CAGradientLayer and apply it as the mask of that view's CALayer, nothing happens. Why? In -initWithFrame: of the view I do this: CAGradientLayer *gradient = [CAGradientLayer layer]; gradient.frame = self.bounds; gradient.colors = [NSArray arrayWithObjects:(id)[[UIColor blackColor] CGColor], (id)[[UIColor whiteColor] CGColor], nil]; //[self.layer insertSublayer:gradient atIndex:0]; self.layer.mask = gradient; If I replace self.layer.mask =

How to change CAGradientLayer color points?

ⅰ亾dé卋堺 提交于 2019-11-27 12:00:39
问题 Right now I've got a GA Gradient layer where I've set the colors but I'd like to set the color point to (instead of top center, to top left) and the bottom to (instead of bottom center to bottom right) just to change things up a bit. Thoughts? Below is the code that I've got so far...I included core animation because I'm animation between colors. - (id)init { self = [super init]; UIView *gradientView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.w, self.h)]; [self addSubview

CAGradientLayer diagonal gradient

99封情书 提交于 2019-11-27 09:53:46
问题 I use the following CAGradientLayer: let layer = CAGradientLayer() layer.colors = [ UIColor.redColor().CGColor, UIColor.greenColor().CGColor, UIColor.blueColor().CGColor ] layer.startPoint = CGPointMake(0, 1) layer.endPoint = CGPointMake(1, 0) layer.locations = [0.0, 0.6, 1.0] But when I set bounds property for the layer, it just stretches a square gradient. I need a result like in Sketch 3 app image (see above). How can I achieve this? 回答1: Update: Use context.drawLinearGradient() instead of

Fade out scrolling UITextView over image?

懵懂的女人 提交于 2019-11-26 20:02:10
问题 I’m looking to fade out a scrolling UITextView over a background image, something similar to the gradient at the top of this little example. I’m trying to work out how I can achieve this using CAGradientLayer and masks. As the text in the view scrolls (vertically), I need the text to become transparent before it hits the frame of the view, to give the illusion that it’s fading out upward and downward. Any tips on how I might achieve this? 回答1: Oh man, I use this a lot. Have it saved as a

CAGradientLayer, not resizing nicely, tearing on rotation

孤街醉人 提交于 2019-11-26 17:10:10
I'm trying to get my CAGradientLayers, that i'm using to create nice gradient backgrounds, to resize nicely on rotation and modal view presentation, but they will not play ball. Here is a video I just created showing my problem: Notice the tearing on rotation. Also please note this video was created by filming the iPhone Simulator on OS X. I have slowed down the animations in the video to highlight my issue. Video of Problem... Here is an Xcode project which I just created (which is the source for the app shown in the video), basically as illustrated the issue occurs on rotation and especially

How to Apply Gradient to background view of iOS Swift App

£可爱£侵袭症+ 提交于 2019-11-26 05:42:55
问题 I\'m trying to apply a gradient as the background color of a View (main view of a storyboard). The code runs, but nothing changes. I\'m using xCode Beta 2 and Swift. Here\'s the code: class Colors { let colorTop = UIColor(red: 192.0/255.0, green: 38.0/255.0, blue: 42.0/255.0, alpha: 1.0) let colorBottom = UIColor(red: 35.0/255.0, green: 2.0/255.0, blue: 2.0/255.0, alpha: 1.0) let gl: CAGradientLayer init() { gl = CAGradientLayer() gl.colors = [ colorTop, colorBottom] gl.locations = [ 0.0, 1.0