core-graphics

iOS: Rendering UITableView into PDF

孤人 提交于 2019-12-11 11:47:52
问题 I have written pdfGenerator class to render whole UITableView to generate PDF. Usage: [pdfGenerator createPDFFromTableview:self.tableView]; Class Methods: - (void)createPDFFromTableview:(UITableView *)tableview { [tableview scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:NO]; [self renderTableView:tableview]; int rows = [tableview numberOfRowsInSection:0]; int numberofRowsInView = 17; for (int i = 0; i < rows

UIImage sideway after converting it from CIImage

…衆ロ難τιáo~ 提交于 2019-12-11 10:17:22
问题 I'm applying filter on UIImage but after conversion, it appear as sideway. Below is my code. CIImage *ciImage = [[CIImage alloc] initWithImage:self.imgToProcess]; CIFilter *filter = [CIFilter filterWithName:@"CIPhotoEffectChrome" keysAndValues:kCIInputImageKey, ciImage, nil]; [filter setDefaults]; CIContext *context = [CIContext contextWithOptions:nil]; CIImage *outputImage = [filter outputImage]; CGImageRef cgImage = [context createCGImage:outputImage fromRect:[outputImage extent]]; UIImage

drawing shadow around a view slows down my transition,CALayer,ios

家住魔仙堡 提交于 2019-12-11 09:40:03
问题 MyViewControllerB.xib contains view( UIView ) | |__image (UIImageView) | |__view (UIView) | |__text (UITextView) | |__view (UIView) ( shadow is adding at here ) Then I am adding a shadow around the view at the bottom as following - (void)viewDidLoad { [super viewDidLoad]; [self.bottomView.layer setMasksToBounds:NO]; self.bottomView.layer.shadowColor = [UIColor blackColor].CGColor; self.bottomView.layer.shadowRadius = 5; self.bottomView.layer.shadowOpacity = 1; self.bottomView.layer

Keeping right tints after image masking

戏子无情 提交于 2019-12-11 09:27:37
问题 I need to fill programmatically image with different colors with mask I got from our designer in photoshop file: http://image.openlan.ru/images/83339350420766181806.png I almost finish this except of details I missed: UIImage *mask = [UIImage imageNamed:@"mask.png"]; UIImage *image = [UIImage imageNamed:@"vehicle.png"]; mask = [image maskImage:image withMask:mask]; image = [image coloredImageWithColor:[UIColor blueColor]]; image = [image drawImage:mask inImage:image]; Where methods

Where am I leaking CGMutablePathRef in this code?

守給你的承諾、 提交于 2019-12-11 09:18:46
问题 In my code I have CGMutablePathRef thePath = CGPathCreateMutable(); If I don't release it I literally get thousands of leaks because I'm doing the action constantly. However, if I do release it, my game eventually crashes. Any ideas? Is it possible I'm releasing it in the wrong place? -(void)MoveObject:(int)Tag { representationX = gameViewObj.spaceshipImageView.center.x; representationY = gameViewObj.spaceshipImageView.center.y; CALayer *spaceshipLayer = gameViewObj.spaceshipImageView.layer;

Correct GraphicsContext When Using UIGraphicsGetImageFromCurrentImageContext

狂风中的少年 提交于 2019-12-11 08:53:32
问题 I have the following method where I'm trying to do some drawing into an image: - (UIImage*) renderImage { UIGraphicsBeginImageContextWithOptions(self.size, NO, 0); CGContextRef context = UIGraphicsGetCurrentContext(); //drawing code UIImage *image = [UIGraphicsGetImageFromCurrentImageContext() retain]; UIGraphicsEndImageContext(); return [image autorelease]; } When I run this code I noticed that I'm getting hit much harder than I did when I was simply drawing this code in drawRect of a UIView

Generate a CGPath from another path's line width outline

荒凉一梦 提交于 2019-12-11 08:28:43
问题 I might not be explaining this in the best way possible, so please bear with me. What I have is a drawn CGPath on top of a MKMapView object: The way I was able to achieve this is to create a CGPath for the darker blue line, then create a copy of that path, and then stroke a thicker version of it with a semi-transparent blue color. Here's the code that I'm currently using for this: // set the shadow around the path line CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSaveGState

Draw one CGlayer into another CGlayer

房东的猫 提交于 2019-12-11 08:23:33
问题 I am using two CGlayers for drawing, Layer1 and Layer2, I draw into Layer1 and on touches end, I transfer the data into Layer2 and just clear Layer1, and in my drawRect, method, I draw both layers to context. On erase button clicked, I transfer the drawing from Layer2 to Layer1 and then I erase layer1, but on touches end, I dont transfer it to Layer2, because I only erase Layer1 On pen clicked If erase has happened, I transfer drawing from Layer1 to Layer2, otherwise previous drawing can

NSString drawInRect: and drop shadows on iOS

依然范特西╮ 提交于 2019-12-11 08:22:47
问题 I'm using [NSString drawInRect:] to draw text to a texture and everything works fine until I add drop shadows. They appear correctly, but are often clipped by the rect I'm drawing to. The issue is that [NSString sizeWithFont:] doesn't know about the drop shadows since they are applied via CGContextSetShadowWithColor(...) . Here is the code I'm using (fluff removed): CGSize dim = [theString sizeWithFont:uifont]; ... CGContextSetRGBFillColor(context, 1.0f, 1.0f, 1.0f, 1.0f);

iOS: Draw clear circle with UIBezierPath bezierPathWithOvalInRect:

时光总嘲笑我的痴心妄想 提交于 2019-12-11 08:15:32
问题 In my UITableViewController 's cells, I want to display a circle with a number in it. I am using UIBezierPath 's bezierPathWithOvalInRect: to draw the circle. Unfortunately, while I can set the fill color to be clearColor , the unused portion of the CGRect passed to bezierPathWithOvalInRect: is black. How do I get rid of the black area created? Partial screenshot for reference: (I eventually hope to get that number inside the circle) Code: LTTTableViewCell: - (void)awakeFromNib { [super