Эх сурвалжийг харах

force initiating preview with correct size

cyberta 4 жил өмнө
parent
commit
355406f12f

+ 6 - 1
DcShare/Controller/ShareViewController.swift

@@ -47,11 +47,16 @@ class ShareViewController: SLComposeServiceViewController {
     var previewImageWidthConstraint: NSLayoutConstraint?
 
     lazy var preview: SDAnimatedImageView? = {
-        let imageView = SDAnimatedImageView(frame: .zero)
+
+        UIGraphicsBeginImageContext(CGSize(width: 96, height: 96))
+        let image = UIGraphicsGetImageFromCurrentImageContext()
+        UIGraphicsEndImageContext()
+        let imageView = SDAnimatedImageView(image: image)
         imageView.clipsToBounds = true
         imageView.shouldGroupAccessibilityChildren = true
         imageView.isAccessibilityElement = false
         imageView.contentMode = .scaleAspectFit
+        imageView.translatesAutoresizingMaskIntoConstraints = false
         previewImageHeightConstraint = imageView.constraintHeightTo(96)
         previewImageWidthConstraint = imageView.constraintWidthTo(96)
         previewImageHeightConstraint?.isActive = true