quartz-core

iOS: Drawing just portions of a UImage

邮差的信 提交于 2019-12-01 06:22:20
问题 I am trying to draw just a custom portion of a UIImage (i.e.: I would like to reveal the portion of the UIImage user touches) and I am having reasonable results by using mask property of the layer . Something like this on my UIView : UIBezierPath *maskPath = [UIBezierPath bezierPath]; [maskPath setLineWidth:10.0]; [maskPath moveToPoint:CGPointMake(10.0, 10.0)]; [maskPath addLineToPoint:CGPointMake(100.0, 100.0)]; CAShapeLayer *shapeMaskLayer = [CAShapeLayer layer]; shapeMaskLayer.path =

Objective-C: Capture screenshot of all views within custom frame

自古美人都是妖i 提交于 2019-11-30 12:37:06
问题 I have a game where users can create custom levels and upload them to my server for other users to play and I want to get a screenshot of the "action area" before the user tests his/her level to upload to my server as sort of a "preview image". I know how to get a screenshot of the entire view, but I want to define it to a custom frame. Consider the following image: I want to just take a screenshot of the area in red, the "action area." Can I achieve this? 回答1: Just you need to make a rect of

Customize UITextfield of the UISearchbar - iOS

≡放荡痞女 提交于 2019-11-30 02:20:41
I'm trying to customize the textfield for the UISearchbar. The picture below shows my half done work. I have subclasses the UISearchbar and called it from my view controller. I'm trying to remove those dark gray lines from the textfield. Below is the implementation of the UISearchbar adding to subview of the viewcontroller. searchbar = [[SearchBar alloc] initWithFrame:CGRectMake(35,78, 250, 17)]; searchbar.backgroundColor = [UIColor clearColor]; searchbar.layer.borderColor = [[UIColor clearColor] CGColor]; searchbar.layer.borderWidth = 0; for(UIView *view in searchbar.subviews){ if([view

Draw a line with a CALayer

柔情痞子 提交于 2019-11-29 01:33:56
I'm trying to draw a line between two points using a CALayer. Here is my code: //positions a CALayer to be a line between a parent node and its subnodes. -(void)makeLineLayer:(CALayer *)layer lineFromPointA:(CGPoint)pointA toPointB:(CGPoint)pointB{ NSLog([NSString stringWithFormat:@"Coordinates: \n Ax: %f Ay: %f Bx: %f By: %f", pointA.x,pointA.y,pointB.x,pointB.y]); //find the length of the line: CGFloat length = sqrt((pointA.x - pointB.x) * (pointA.x - pointB.x) + (pointA.y - pointB.y) * (pointA.y - pointB.y)); layer.frame = CGRectMake(0, 0, 1, length); //calculate and set the layer's center:

Quartz Core Import not required in Xcode 5?

百般思念 提交于 2019-11-29 01:20:00
Just stumbled across this today. I am getting warnings in Xcode 4.6 if I try to access the CALayer without importing <QuartzCore/QuartzCore.h> . The same however works fine in Xcode 5. Yes, <QuartzCore/QuartzCore.h> is automatically included, but this seems to be more a side effect than intended, because it is included only indirectly: <UIKit/UIKit.h> includes <UIKit/UISlider.h> , in the iOS 7 SDK, <UIKit/UISlider.h> includes <QuartzCore/QuartzCore.h> , due to new instance variables in the UISlider class (of the CAShapeLayer type). In addition, Xcode 5 has a new build setting "Link Frameworks

How to access iOS private APIs in Swift?

荒凉一梦 提交于 2019-11-28 09:09:59
How can I call non-public iOS functions and acces non public properies from Swift? Specifically, I would like to use one non-public class in QuartzCore framework. One solution that came to my mind is to create "bridging" Objective-C project that would wrap this non-public APIs into public ones and than call this Objective-C functions from Swift. However, my solution is pure Swift now and I would prefer to keep it that way. Is there any more staitforward way? (for example adding something to Objective-C bridging header file ) Note: I know what you are thinking, private APIs are private because

color replacement in image for iphone application

被刻印的时光 ゝ 提交于 2019-11-28 04:13:36
Basically i want to implement color replacement feature for my paint application. Below are original and expected output Original: After changing wall color selected by user along with some threshold for replacement I have tried two approaches but could not got working as expected Approach 1: Queue-based Flood Fill algorithm for color replacement but with i got below output with terribly slow and wall shadow has not been preserved. Approach 2: So i have tried to look at another option and found below post from SO How to change a particular color in an image? but i could not understand logic

Bordered UITextView

南笙酒味 提交于 2019-11-27 17:18:59
I want to have a thin gray border around a UITextView . I have gone through the Apple documentation but couldn't find any property there. Please help. #import <QuartzCore/QuartzCore.h> .... // typically inside of the -(void) viewDidLoad method self.yourUITextView.layer.borderWidth = 5.0f; self.yourUITextView.layer.borderColor = [[UIColor grayColor] CGColor]; user542584 Add the following for rounded corners: self.yourUITextview.layer.cornerRadius = 8; Here's the code I used, to add a border around my TextView control named "tbComments" : self.tbComments.layer.borderColor = [[UIColor grayColor]

Adding quartzcore to Xcode 4 for iOS

我的未来我决定 提交于 2019-11-27 15:02:23
I have troubles installing quartzcore on Xcode 4 regarding an iOS application. I just can't find the answer: how to do it? Because when I try to add Quartzcore to the targets of the project, it seems I can only add a Mac OS X framework. All you can do about an iOS framework is creating one. foslock In Xcode 4, in the left sidebar, select the project file at the top: 1) Make sure your target is selected in the main view, and you should see 5 tabs at the top, 2) Click the "Build Phases" tab, 3) Click the arrow to the left of the "Link Binary With Libraries" row, 4) Click the plus button that

How to draw radial gradients in a CALayer?

ぃ、小莉子 提交于 2019-11-27 06:34:29
I know CAGradientLayer doesn't support radial gradient at the moment and only has option of kCAGradientLayerAxial . I want something like below: I have looked around for this issue and found that there is a way around this. But the explanations were not clear to me. So I want to know if I can draw radial gradients using CAGradientLayer and if so, then how to do it? Mazyod From what I understood, you just need a layer that draws a gradient, and CGContextDrawRadialGradient works perfectly for that need. And to reiterate on what you said, CAGradientLayer doesn't support radial gradients, and