I'm developing an application with swift, saving png images with UserDefaults and displaying them on multiple screens
When creating an image, I want to reflect it because it is made transparent
Applicable source code
I can display it on the screen, but when I read it, the background becomes white without being transparent
Save UserDefaults.standard.set (selectedImage! .JpegData (compressionQuality: 1.0), forKey: "imageData") Read let imageDate: NSData = UserDefaults.standard.object (forKey: "imageData") as! NSData selectedFriends.image = UIImage (data: imageDate as Data)
If i put the image in the imageview as it is, the background is transparent, so there is no problem with the image itselfSupplemental information (FW/tool version etc.)
Swift version is 5
Answer # 1
selectedImage! .jpegData (compressionQuality: 1.0)
Isn't it a problem to extract NSData in JPEG format?
What happens if I extract it in PNG format using pngData ()?
Answer # 2
JPEG format does not have the concept of transparency.
Even if the image is transparent, the transparency information will be lost when converted to JPEG.
let imageDate: NSData = UserDefaults.standard.object (forKey: "imageData") as! NSData
nilis returned when there is nothing in UserDefaults at the first startup.
Be careful as force cast can fail.
- ios - [swift] i want to display the image dialog
- swift - when i try to display an image on actionsheet, only a blue square is displayed
- how to play and display transparent gif and background gif at the same time with wxpython
- html - no background image is displayed how can i display it?
- css - how to display the background in the margin in an image file such as a logo
- java - how to display background image in jsp
- xcode - i want to display text on top of an image in swift, but i get an exception
- html - i want to display a background image when fading in/out the image with slickjs
- html - i want to display the logo and background image in order by fading in
- css3 - i want to display the image from below
- python - tkinter image display error
- php - laravel image display does not work well
- how to display the image registered with ole object in currentdb of access with vba in form
- website - image display error in vscode
- html - i want to overlay dot with image using background property
- css - background image is not at the bottom
- php - get the svg code saved in db and display it as an image in html
- swift - the display of collectionview is centered
- html - the background image is not reflected in css
- html - [css] how to display a square image according to the window width
- php - coincheck api authentication doesn't work
- php - i would like to introduce the coincheck api so that i can make payments with bitcoin on my ec site
- [php] i want to get account information using coincheck api
- python - you may need to restart the kernel to use updated packages error
- python 3x - typeerror: 'method' object is not subscriptable
- the emulator process for avd pixel_2_api_29 was killed occurred when the android studio emulator was started, so i would like to
- xcode - pod install [!] no `podfile 'found in the project directory
- vuejs - [vuetify] unable to locate target [data-app] i want to unit test to avoid warning
- android studio - unresolved reference comes out in kotlin