Explorar el Código

force initiating preview with correct size

cyberta hace 4 años
padre
commit
355406f12f
Se han modificado 1 ficheros con 6 adiciones y 1 borrados
  1. 6 1
      DcShare/Controller/ShareViewController.swift

+ 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