uiimage

swift uitextview html image causes crash when copy image is selected after long press

两盒软妹~` 提交于 2021-02-11 12:32:22
问题 I currently have a UITextView that is displaying an NSAttributedString that contains HTML data with text and images. This data is received via API so images and text are all combined into one HTML string. This is the function that parses the HTML. let htmlData = NSString(string: myString).data(using: String.Encoding.unicode.rawValue); let options = [NSAttributedString.DocumentReadingOptionKey.documentType: NSAttributedString.DocumentType.html]; do{ let text = try NSMutableAttributedString

UImage? isn't convertible to UIImage: Xcode throws error when trying to use original image

亡梦爱人 提交于 2021-02-08 12:02:30
问题 func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) { // The info dictionary may contain multiple representations of the image. You want to use the original. guard let selectedImage = info[.originalImage] as? UIImage else { fatalError("Expected a dictionary containing an image, but was provided the following: \(info)") } // Set photoImageView to display the selected image. photoImageView.image = selectedImage // Dismiss the picker.

How to make an ellipse/circular UIImage with transparent background?

£可爱£侵袭症+ 提交于 2021-02-08 09:51:28
问题 This is the code I am using extension UIImage { var ellipseMasked: UIImage? { guard let cgImage = cgImage else { return nil } let rect = CGRect(origin: .zero, size: size) return UIGraphicsImageRenderer(size: size, format: imageRendererFormat) .image{ _ in UIBezierPath(ovalIn: rect).addClip() UIImage(cgImage: cgImage, scale: scale, orientation: imageOrientation) .draw(in: rect) } } } This is the image I got The background color is black. How can I make the background transparent? I tried

How to save UIImage after Editing with Pan, Rotate and Pinch Gesture

跟風遠走 提交于 2021-02-07 19:43:35
问题 I'm trying to implement edit image using UIPanGesture, UIRotateGesture, and UIPinchGesture. After editing, I wish to save edited UIImage. I'm done edit image functionality. But I don't know How to save exactly perfect like native iOS Camera App. Pan Gesture is working fine. My problem is Rotate and Scale. How to set center anchor point of UIImage? When I saved UIImage from transform information then the result of UIImage is looks different because Rotate and Scale, then It always applied

How to make a UIImage Scrollable inside a UIScrollView?

自作多情 提交于 2021-02-07 10:39:54
问题 I currently have a ScrollView and inside the ScrollView i have a UIImageView . I get different image sizes from my server and most images are larger than the bounds of my screen. I would like to scroll through the image if it is bigger than my screen. Something like this.... This is what i have tried so far. let image = UIImage(named: "myImg") let heightInPoints = image?.size.height let heightInPixels = heightInPoints ?? 0 * image!.scale let widthInPoints = image?.size.width let widthInPixels

UIImage Crop Out Transparent Pixels

早过忘川 提交于 2021-02-07 07:32:12
问题 I need help to create perfect clear image after cropping transparent pixel from UIImage using swift 4. I want to create image with remove transparent color, So for that i have used below code. But it blur image with small small square rectangles appears. Using of below code let imageCroppedBg = imgWithClearBackgroung!.cropAlpha() //UIImage extension extension UIImage { func cropAlpha() -> UIImage { let cgImage = self.cgImage!; let width = cgImage.width let height = cgImage.height let

How do I mirror a UIImage picture from UIImagePickerController

十年热恋 提交于 2021-02-06 15:16:25
问题 I'm trying to figure out if there is any way to mirror an image. For example, take a picture of someone's face and then cut it in half and show what their face looks like with each side mirrored. There doesn't seem to be any tricks like this in CGAffineTransform functions. Graphics experts please help!!! 回答1: The basic "trick" here is to use a scaling transform about the X or Y axis with a factor of -1. For example, you could use this to create a "flip about the horizontal axis" transform:

How do I mirror a UIImage picture from UIImagePickerController

孤街醉人 提交于 2021-02-06 15:14:02
问题 I'm trying to figure out if there is any way to mirror an image. For example, take a picture of someone's face and then cut it in half and show what their face looks like with each side mirrored. There doesn't seem to be any tricks like this in CGAffineTransform functions. Graphics experts please help!!! 回答1: The basic "trick" here is to use a scaling transform about the X or Y axis with a factor of -1. For example, you could use this to create a "flip about the horizontal axis" transform:

Creating a thumbnail from UIImage using CGImageSourceCreateThumbnailAtIndex

梦想与她 提交于 2021-02-05 20:14:36
问题 I want to use the function CGImageSourceCreateThumbnailAtIndex to create a thumbnail from an UIImage . All I have is the UIImage itself. The image is the snapshot on a UIView . Please, I don't want to use any other method to create the thumbnail, just the one using CGImageSourceCreateThumbnailAtIndex , because I want to compare its performance with the other methods I already have. Said that, this is the code I have so far. I have create a UIImage category with this code: - (UIImage *

Creating a thumbnail from UIImage using CGImageSourceCreateThumbnailAtIndex

不想你离开。 提交于 2021-02-05 20:11:14
问题 I want to use the function CGImageSourceCreateThumbnailAtIndex to create a thumbnail from an UIImage . All I have is the UIImage itself. The image is the snapshot on a UIView . Please, I don't want to use any other method to create the thumbnail, just the one using CGImageSourceCreateThumbnailAtIndex , because I want to compare its performance with the other methods I already have. Said that, this is the code I have so far. I have create a UIImage category with this code: - (UIImage *