quartz-core

Custom CALayer - invalid context 0x0

旧街凉风 提交于 2019-12-03 16:55:43
I'm trying to build an app that use layers, my app structure is UIView --> UIScrollView --> UIView --> LayersView (Custom UIView) --> UIImageView I want to add multiple layers to the LayersView, so I've build a custom CALayer that use UIBezierPath to draw a set of points. CALayerBezierPath.h #import <QuartzCore/QuartzCore.h> @interface CALayerBezierPath : CALayer { NSMutableArray *pointsArray; } @property (nonatomic, retain) NSMutableArray *pointsArray; - (void) initVariables; - (void) addNewPoints:(CGPoint)newPoint; @end CALayerBezierPath.m #import "CALayerBezierPath.h" @implementation

Is Rounded Corners on Attributed Text Background possible?

纵饮孤独 提交于 2019-12-03 16:02:13
I attributed Text with different textcolors. For better readability on highlighted text i use backgroundcolor. Is it possible to bring the CALayer Effect of Rounded Corners on this Textarea? Not the whole Area but the special Text inside of it. My Code: NSAttributedString *text = [[NSAttributedString alloc] initWithString:@"Highlighted Text" attributes:@{ NSFontAttributeName: [UIFont fontWithName:@"HelveticaNeue" size:10.0f], NSForegroundColorAttributeName: [UIColor lightGrayColor], NSBackgroundColorAttributeName: [UIColor darkGrayColor] }]; 来源: https://stackoverflow.com/questions/19144145/is

Stroke masked CALayer in iOS

纵饮孤独 提交于 2019-12-03 12:02:52
问题 I'm trying to create a label (or any other view for that matter) with one rounded corner and a stroke/border. I can achieve the former using the following code: UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.label.bounds byRoundingCorners:UIRectCornerBottomRight cornerRadii:CGSizeMake(16.0f, 16.0f)]; CAShapeLayer *shape = [CAShapeLayer layer]; shape.frame = self.label.bounds; shape.path = maskPath.CGPath; self.label.layer.mask = shape; Which works great for the rounded

cancel a UIView animateWithDuration before completion

流过昼夜 提交于 2019-12-03 10:06:17
I have this code in my project: - (void) fadeImageView { [UIView animateWithDuration:1.0f delay:0 options:UIViewAnimationCurveEaseInOut animations:^{ self.imageView.alpha = 0.0f; } completion:^(BOOL finished) { //make the image view un-tappable. //if the fade was canceled, set the alpha to 1.0 }]; } however, there are circumstance where i would like to cancel this operation before the imageview has become invisible. Is there a way to cancel this animation mid animation? Update: prefer this answer https://stackoverflow.com/a/21527129/194309 from Borut Tomazin Borut Tomazin From Apple docs: Use

CAShapeLayer animation (arc from 0 to final size)

家住魔仙堡 提交于 2019-12-03 06:39:28
I have a CAShapeLayer in which an arc is added using UIBezierPath . I saw a couple of posts (one actually) here on stackoverflow but none seemed to give me the answer. As said in the title I would like to animate an arc (yes it will be for a pie chart). How can one accomplish an animation from an "empty" arc to the fully extended one? Kinda like a curved progress bar. Is it really impossible to do it via CoreAnimation ? Here's how I "do" the arc. Oh and ignore the comments and calculation since I'm used to counter clockwise unit circle and apple goes clockwise. The arcs appear just fine, I

How to add Stretchable UIImage in the CALayer.contents?

拜拜、爱过 提交于 2019-12-03 05:11:07
问题 I have a CALayer and I want to add to it a stretchable image. If I just do: _layer.contents = (id)[[UIImage imageNamed:@"grayTrim.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0.0, 15.0, 0.0, 15.0)].CGImage; it won't work since the layers' default contentGravity is kCAGravityResize. I've read that this could be accomplished using the contentsCenter but I cannot seem to figure out how exactly would I use that to achieve the stretched image in my CALayer. Any ideas are welcome! Horatiu 回答1

Stroke masked CALayer in iOS

南楼画角 提交于 2019-12-03 02:23:12
I'm trying to create a label (or any other view for that matter) with one rounded corner and a stroke/border. I can achieve the former using the following code: UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.label.bounds byRoundingCorners:UIRectCornerBottomRight cornerRadii:CGSizeMake(16.0f, 16.0f)]; CAShapeLayer *shape = [CAShapeLayer layer]; shape.frame = self.label.bounds; shape.path = maskPath.CGPath; self.label.layer.mask = shape; Which works great for the rounded corner, but using the following code doesn't apply the stroke the way I want. Instead producing a black

How to add Stretchable UIImage in the CALayer.contents?

时间秒杀一切 提交于 2019-12-02 17:35:58
I have a CALayer and I want to add to it a stretchable image. If I just do: _layer.contents = (id)[[UIImage imageNamed:@"grayTrim.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0.0, 15.0, 0.0, 15.0)].CGImage; it won't work since the layers' default contentGravity is kCAGravityResize. I've read that this could be accomplished using the contentsCenter but I cannot seem to figure out how exactly would I use that to achieve the stretched image in my CALayer. Any ideas are welcome! Horatiu The response to this question is this one. Lets say you have a stretchable image which stretches only in

How to show all supported resolutions for display in mac app

拜拜、爱过 提交于 2019-12-02 16:44:57
问题 I want to show all compatable resolution for screen but getting only few resolutions, the resolutions which i am getting when passing nil to CGDisplayCopyAllDisplayModes same resolutions i am getting even if i pass kCGDisplayShowDuplicateLowResolutionModes to kCFBooleanTrue Below block which i am using. +(NSArray *)menuItemsForCurrentDisplay :(CGDirectDisplayID)display{ //Get Current mode CGDisplayModeRef currentMode = CGDisplayCopyDisplayMode(display); // Use a dictionary with title keys to

How to show all supported resolutions for display in mac app

橙三吉。 提交于 2019-12-02 07:41:23
I want to show all compatable resolution for screen but getting only few resolutions, the resolutions which i am getting when passing nil to CGDisplayCopyAllDisplayModes same resolutions i am getting even if i pass kCGDisplayShowDuplicateLowResolutionModes to kCFBooleanTrue Below block which i am using. +(NSArray *)menuItemsForCurrentDisplay :(CGDirectDisplayID)display{ //Get Current mode CGDisplayModeRef currentMode = CGDisplayCopyDisplayMode(display); // Use a dictionary with title keys to avoid 'duplicates' NSMutableDictionary *menuItemsByTitle = [NSMutableDictionary new]; // Get Number of