uigraphicscontext

Create multi page PDF in objective-c

跟風遠走 提交于 2019-12-03 07:43:36
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]; NSMutableArray *arrSelectedCities = [[mutDictValues objectForKey:@"cities"]mutableCopy ]; if

extension function screenshot not capturing the same area in iphone and ipad

牧云@^-^@ 提交于 2019-12-02 17:59:53
问题 I am using a extension function to take a screenshot of a uiview. The problem is that the results look very different. I want the photo to look the same regardless of weather its a ipad or iphone. I am manually entering the constraints so I expect the images to be the same. I want to using the function to go to the orgin or center of the viewcontroller and be 200 height and 200 width. So the image should be the same regardless of the device because it starts in the center and is the same size

Image gets blurry and zoomed out when erasing

我只是一个虾纸丫 提交于 2019-12-01 16:27:06
问题 I am using functionality of erasing image and my code is like below. You can see Video HERE. Here current_sticker_img is my Imageview NOTE: I am also using Pan Gesture for zooming image //MARK: Eraser touch event override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) { if btn_eraser.isSelected == true || btn_repaint.isSelected == true{ let touch : UITouch = touches.first! lastpoint = touch.location(in: current_sticker_img) } } override func touchesMoved(_ touches: Set

Swift: Cropping a Screenshot without TabBar and NavigationBar

烂漫一生 提交于 2019-11-30 20:43:43
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: let crop = CGRectMake(0, 0, //"start" at the upper-left corner self.view.bounds.width, //include half

FileManager says file doesn't exist when it does

£可爱£侵袭症+ 提交于 2019-11-30 17:45:51
问题 I have a use case that requires a UIImage to be saved to the documents directory - then the UIImage needs to be converted into a PDF and saved to the documents directory. CODE TO CONVERT TO PDF var filePath = NSString(string: self.selectedMedia!.imagePath!) if FileManager().fileExists(atPath: filePath as String) { filePath = filePath.deletingPathExtension as NSString filePath = NSString(string: filePath.appendingPathExtension("PDF")!) if let image = UIImage(data: self.selectedMedia?.image! as

How to take screen shot programmatically (Swift, SpriteKit)

狂风中的少年 提交于 2019-11-30 14:56:56
问题 I tried what ever was suggested but the output was a white,blank screenshot. Which leads me to assume that I haven't added anything to the view. Here's how I'm adding graphics to my view. The addChild method comes with the SpriteKit and it takes in SKSpriteNodes: addChild(background) addChild(rate) addChild(scoreLabel) addChild(share) addChild(playAgain) addChild(highScoreLabel) addChild(scoreBackground) addChild(highScoreBackground) Here's the method that takes the screenshot:

Convert PDF to UIImage

梦想与她 提交于 2019-11-30 09:11:59
func drawOnPDF(path: String) { // Get existing Pdf reference let pdf = CGPDFDocumentCreateWithURL(NSURL(fileURLWithPath: path)) // Get page count of pdf, so we can loop through pages and draw them accordingly let pageCount = CGPDFDocumentGetNumberOfPages(pdf); // Write to file UIGraphicsBeginPDFContextToFile(path, CGRectZero, nil) // Write to data // var data = NSMutableData() // UIGraphicsBeginPDFContextToData(data, CGRectZero, nil) for index in 1...pageCount { let page = CGPDFDocumentGetPage(pdf, index) let pageFrame = CGPDFPageGetBoxRect(page, kCGPDFMediaBox) UIGraphicsBeginPDFPageWithInfo

Convert PDF to UIImage

对着背影说爱祢 提交于 2019-11-27 15:17:59
问题 func drawOnPDF(path: String) { // Get existing Pdf reference let pdf = CGPDFDocumentCreateWithURL(NSURL(fileURLWithPath: path)) // Get page count of pdf, so we can loop through pages and draw them accordingly let pageCount = CGPDFDocumentGetNumberOfPages(pdf); // Write to file UIGraphicsBeginPDFContextToFile(path, CGRectZero, nil) // Write to data // var data = NSMutableData() // UIGraphicsBeginPDFContextToData(data, CGRectZero, nil) for index in 1...pageCount { let page =

Rounding UIImage and adding a border

前提是你 提交于 2019-11-27 02:54:06
问题 so I want to show some pictures as annotations on the map. In order to do that I need to add the image property of the MKAnnotationView. I'm using the regular images but I want them to be rounded and with a border. So I found a way to round UIImage and I found the way to add a border to UIImage, but border doesn't seem to add (I'm not actually having the image on the screen, maybe that is the problem?). I used this answer https://stackoverflow.com/a/29047372/4665643 with a slight modification