uigraphicscontext

renderInContext taxes App Memory

自作多情 提交于 2019-12-22 08:07:29
问题 I'm running this code on a 2448 X 2448 pixel Image. fullScaleView is also 2448 X 2448 ( fullScreenView Rect:{{0, 0}, {2448, 2448}} ). The App memory jumps from 49.7MB to 240MB down to 172MB after the method is complete. It stays at 172MB. It doesn't seem like the app should still be running at such high a memory footprint after this one renderInContext . Where and how should I force a release? (iOS 7 XCode 5 ARC). UIGraphicsBeginImageContextWithOptions(fullScaleView.bounds.size, fullScaleView

Add Text on UIImage

风流意气都作罢 提交于 2019-12-21 19:24:34
问题 Hi I am using this function to draw text on Image after the drawing on image is done but when I do this its showing me transparent text i.e. Text with opacity which I do not want it should be with alpha 1.0 I tried to add the fontcolor attribute with RGBA but dint work -(UIImage*) drawText:(NSString*) text inImage:(UIImage*) image atPoint:(CGPoint) point atSize :(CGSize) size { //[NSLog(@"Drawing Text on the Image : Text Posn x:%f y:%f ",point.x,point.y); UIGraphicsBeginImageContext(

Create multi page PDF in objective-c

一世执手 提交于 2019-12-21 02:43:43
问题 I am trying to create a multipage PDF. I have followed this tutorial. This is working with a XIB file for static text and then adds a table from code. But the problem I'm having ATM is that when the table is bigger then one page. When the table has more then 9 rows. It should continue on the next page. This is what I'm doing in code. +(void)drawPDF:(NSString*)fileName { NSMutableDictionary *mutDictValues = [[[NSUserDefaults standardUserDefaults] objectForKey:@"dicValues"] mutableCopy];

UIImage fill transparent part with another image

我们两清 提交于 2019-12-20 04:04:25
问题 I would like to fill the transparent part of an image with another image in iOS. I have tried some stuff with UIGraphicsContext , but I can't get it working because I've never used that before. Here is the image: Some code I tried: UIImageView *v = [[UIImageView alloc] initWithFrame:CGRectMake(100, 100, 70, 70)]; UIGraphicsBeginImageContextWithOptions(v.frame.size, YES, 0); CGContextRef context = UIGraphicsGetCurrentContext(); // beach image UIImage *img = [UIImage imageNamed:@"zivogosce

Swift: Cropping a Screenshot without TabBar and NavigationBar

ⅰ亾dé卋堺 提交于 2019-12-19 03:14:42
问题 I have a screenshot of the entire screen, screenshot , generated using the following: let layer = UIApplication.sharedApplication().keyWindow!.layer let scale = UIScreen.mainScreen().scale UIGraphicsBeginImageContextWithOptions(layer.frame.size, false, scale); layer.renderInContext(UIGraphicsGetCurrentContext()) let screenshot = UIGraphicsGetImageFromCurrentImageContext() UIGraphicsEndImageContext() I'd like to crop it so that the tab bar is not included, and I tried using the following code:

ios Sprite Kit screengrab?

旧城冷巷雨未停 提交于 2019-12-17 15:32:56
问题 I am trying to get a screen grab of a view that has a SKScene in it. The technique I am using is: UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, NO, scale); [self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); This works great with normal UIViews, but for whatever reason it is ignoring all the sprites in the SKScene. I'm not sure if this is a bug, or if Sprite Kit's

Memory Leak in Objective C function with ARC

耗尽温柔 提交于 2019-12-13 05:17:21
问题 here is the function from the library MGSpotyViewController, but I am asking what to watch out in this kind of situations. I am used to C++ and maintaining my own objects but I can't find the problem here. I tried very basic pieces of codes with UIGraphicsBeginImageContextWithOptions and memory still increased slightly but I wasn't sure if I located the problem or that's because the GC hasn't run yet. To test the following function I did: - (BOOL)application:(UIApplication *)application

color of cgpoint changes all lines and should only change new lines

ⅰ亾dé卋堺 提交于 2019-12-11 14:29:45
问题 My code uses to classes. When the function dizzy is called it changes the color of all the lines in the uiview. What I want it to do is only change lines colors that are drawn after the function is called. It should not change the color of the lines that are already drawn like it does now. class ViewController: UIViewController { @objc func dizzy() { canvas.strokeColor = .gray } var canvas = Canvas() } class Canvas: UIView { var strokeColor = UIColor.green { didSet { self.setNeedsDisplay() }

Crop image in swift

家住魔仙堡 提交于 2019-12-11 10:48:05
问题 I am trying to crop image in swift. I'm trying to implement something like, user will capture a photo. Once photo is captured user will be allowed to set the crop area. I'm able to get the image from that crop area, but I want that the crop image should be resized to particular width and height. That is, if particular height or width is smaller then it should be resized. This image should be of frame of it's maximum width and height. Currently it is just adding transparency to the other area.

Printing shinobi chart into PDF

不打扰是莪最后的温柔 提交于 2019-12-10 23:39:01
问题 I have several shinobicharts in my App that I want to print into a PDF file. Everything else, like normal views, labels and images work fine, even the grid, legend and gridlabels are displayed. The only thing missing are the series. So basically I get an empty chart printed into the PDF file. I print the PDF as follows: NSMutableData * pdfData=[NSMutableData data]; PDFPage1ViewController *pdf1 = [self.storyboard instantiateViewControllerWithIdentifier:@"PDF1"]; pdf1.array1 = array1; pdf1