Post

Replies

Boosts

Views

Activity

Reply to how to interpret "scale"
Actually, the reason that makes me to focus on "scale" is about "gesture recognizer handler".@objc func adjustFaceCardScale(byHandlingGestureRecognizerBy recognizer: UIPinchGestureRecognizer){ switch recognizer.state { case .changed,.ended: faceCardScale *= recognizer.scale recognizer.scale = 1.0 default: break } }If I get rid of "recognizer.scale = 1.0". The image size of faceCard will change rapidly, not as expected. How it works?
Mar ’20
Reply to how to interpret "scale"
"line 05" is the key to the problem. The image size of faceCard will change exactly as expected, getting larger or smaller gradually according to pinching. However, without "line 05", the image size change drastically, just something like "exponential" effect. How to interpret it?
Mar ’20
Reply to Read image from asset catalog
I drag a image.jpg into the assets.xcassets. Then you have added an Image Set of name image to the Asset catalogue, not Data Set. You may need to use UIImage.init(named:). Or else if you want to use NSDataAsset, you need to add a Data Set It works for me. I make a new data set, and drag the image into it. Thanks a lot. The only flaw is that it would not to provide "1x、2x、3x" options for resources like image set. :( BTW, is "UIImage(named:)" the only way to retrieve image data from image set in assets catalog? Are there other feasible methods, like by url, Data-like object, or ...? UIImage is a bit expensive for sizing and to resizing.
Apr ’21
Reply to Read image from asset catalog
I'm writing a little app which will present some HD images. I need to keep the memory from spiking up. I fall back on ImageIO which needs images' data or url as input parameters. If choose "url", I have not yet found a way to get urls of images in assets catalog. I don't want to put images in main bundle directly either. Therefore, it seems like I have to choose to retrieve images' data. I try to use UIImage.jpegData(compressionQuality: ) and NSDataSet.data both. Final result is NSDataSet could save 10mb memory per image than UIImage.
Apr ’21