uiimage

Can you convert uiview that is not currently being displayed to uiimage

佐手、 提交于 2020-08-10 02:50:03
问题 I have found numerous examples of converting UIView to UIImage, and they work perfectly for once the view has been laid out etc. Even in my view controller with many rows, some of which are net yet displaying on the screen, I can do the conversion. Unfortunately, for some of the views that are too far down in the table (and hence have not yet been "drawn"), doing the conversion produces a blank UIImage. I've tried calling setNeedsDisplay and layoutIfNeeded, but these don't work. I've even

Can you convert uiview that is not currently being displayed to uiimage

烂漫一生 提交于 2020-08-10 02:45:02
问题 I have found numerous examples of converting UIView to UIImage, and they work perfectly for once the view has been laid out etc. Even in my view controller with many rows, some of which are net yet displaying on the screen, I can do the conversion. Unfortunately, for some of the views that are too far down in the table (and hence have not yet been "drawn"), doing the conversion produces a blank UIImage. I've tried calling setNeedsDisplay and layoutIfNeeded, but these don't work. I've even

AVCaptureSession captured photo's size different than the preview?

China☆狼群 提交于 2020-06-17 15:58:26
问题 These two images are the camera preview and the resulting capture (in that order, respectively [taken via screenshots]). We want the captured photo to match the preview/vice versa. How can we address this? Tried manipulating the CALayer containing the photo data to size the image like how a Xamarin.Forms' image sizes with AspectFit by assigning the ContentsGravity with various options like kCAGravityResizeAspect . Fiddled with other Contents options such as ContentsRect and ContentsScale but

UIScrollView zoom uiview to aspect fill

点点圈 提交于 2020-06-17 15:47:49
问题 I have an image in the UIScrollView and I'm trying to make it aspect fill by default, the code below scale it as listed on the first attached image. But it's not what I expect, how to scale it properly? func aspectFill() { let imageSize = imageZoomView.bounds.size let xScale = bounds.width / imageSize.width let yScale = bounds.height / imageSize.height zoomScale = max(xScale, yScale) } But the expected result is 回答1: Make sure your image view is set to .scaleToFill . When you load your image,

Why will Xcode 9.4.1 not allow me to use the UIImage pngData() instance method?

若如初见. 提交于 2020-06-13 07:56:36
问题 I am trying to use the pngData() instance method of the UIImage class of Apple's UIKit Framework according to this documentation: https://developer.apple.com/documentation/uikit/uiimage/1624096-pngdata When I type the method in Xcode, I get an error saying: Value of type 'UIImage?' has no member 'pngData' override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. let image = UIImage(named: "moroni.png") let dataImage = image

Why will Xcode 9.4.1 not allow me to use the UIImage pngData() instance method?

本秂侑毒 提交于 2020-06-13 07:56:22
问题 I am trying to use the pngData() instance method of the UIImage class of Apple's UIKit Framework according to this documentation: https://developer.apple.com/documentation/uikit/uiimage/1624096-pngdata When I type the method in Xcode, I get an error saying: Value of type 'UIImage?' has no member 'pngData' override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. let image = UIImage(named: "moroni.png") let dataImage = image

Convert UIImage to base64 string in swift

空扰寡人 提交于 2020-06-12 09:05:45
问题 I'm trying to convert a UIImage to a base64 string with the goal of uploading it to a back-end server. However, the conversion code I found in this article (which should be Apple's own implementation) generates an invalid string: Convert between UIImage and Base64 string After upload, I get this image: [Failty image that is decoded from iOS converted base64 1 Instead of this: [Correct image decoded from an online base64 conversion tool2 I tested the upload results using Postman and the back

Load PDF into UIImage or UIImageView?

一曲冷凌霜 提交于 2020-06-12 03:33:36
问题 This is my first ever question on stackoverflow. I'm trying to load a PDF file stored in Resources into a UIImage/UIImageView object in the iPhone SDK. Is this at all possible without converting the PDF to an image? If not, what are the member functions for converting a PDF into a PNG? I would really prefer to preserve the PDF if at all pssoible. Thanks so much for the help! 回答1: PDFs can be loaded by UIWebView. If you need more control you can use Quartz 2D to render PDFs: Quartz2D 回答2: Now

Snapshotting a `UIView` crashes the app with `NSInvalidArgumentException` “[_UIReplicantView _isSymbolImage]: unrecognized selector sent to instance”

倾然丶 夕夏残阳落幕 提交于 2020-06-01 05:09:41
问题 Hi guys i have just updated XCode to version 11.4 from the app store and when i try to snapshot a UIView on iOS 13.4 like this: extension UIView { func snapshot(at scale: CGFloat) -> UIImage? { let renderer = UIGraphicsImageRenderer(size: bounds.size) let image = renderer.image { [weak self] context in self?.drawHierarchy(in: self?.bounds ?? .zero, afterScreenUpdates: true) } return image } } or like that: extension UIView { func snapshotOld(at scale: CGFloat) -> UIImage? {

Snapshotting a `UIView` crashes the app with `NSInvalidArgumentException` “[_UIReplicantView _isSymbolImage]: unrecognized selector sent to instance”

强颜欢笑 提交于 2020-06-01 05:09:08
问题 Hi guys i have just updated XCode to version 11.4 from the app store and when i try to snapshot a UIView on iOS 13.4 like this: extension UIView { func snapshot(at scale: CGFloat) -> UIImage? { let renderer = UIGraphicsImageRenderer(size: bounds.size) let image = renderer.image { [weak self] context in self?.drawHierarchy(in: self?.bounds ?? .zero, afterScreenUpdates: true) } return image } } or like that: extension UIView { func snapshotOld(at scale: CGFloat) -> UIImage? {