Selaa lähdekoodia

Respect input indicator frame

onevcat 8 vuotta sitten
vanhempi
commit
9d35a010b6
2 muutettua tiedostoa jossa 5 lisäystä ja 2 poistoa
  1. 4 1
      Sources/ImageView+Kingfisher.swift
  2. 1 1
      Sources/Indicator.swift

+ 4 - 1
Sources/ImageView+Kingfisher.swift

@@ -204,7 +204,10 @@ extension Kingfisher where Base: ImageView {
             
             
             // Add new
             // Add new
             if var newIndicator = newValue {
             if var newIndicator = newValue {
-                newIndicator.view.frame = base.frame
+                // Set default indicator frame if the view's frame not set.
+                if newIndicator.view.frame != .zero {
+                    newIndicator.view.frame = base.frame
+                }
                 newIndicator.viewCenter = CGPoint(x: base.bounds.midX, y: base.bounds.midY)
                 newIndicator.viewCenter = CGPoint(x: base.bounds.midX, y: base.bounds.midY)
                 newIndicator.view.isHidden = true
                 newIndicator.view.isHidden = true
                 base.addSubview(newIndicator.view)
                 base.addSubview(newIndicator.view)

+ 1 - 1
Sources/Indicator.swift

@@ -164,6 +164,7 @@ class ImageIndicator: Indicator {
 
 
         animatedImageIndicatorView = ImageView()
         animatedImageIndicatorView = ImageView()
         animatedImageIndicatorView.image = image
         animatedImageIndicatorView.image = image
+        animatedImageIndicatorView.frame = CGRect(x: 0, y: 0, width: image.size.width, height: image.size.height)
         
         
         #if os(macOS)
         #if os(macOS)
             // Need for gif to animate on macOS
             // Need for gif to animate on macOS
@@ -171,7 +172,6 @@ class ImageIndicator: Indicator {
             self.animatedImageIndicatorView.canDrawSubviewsIntoLayer = true
             self.animatedImageIndicatorView.canDrawSubviewsIntoLayer = true
         #else
         #else
             animatedImageIndicatorView.contentMode = .center
             animatedImageIndicatorView.contentMode = .center
-            
             animatedImageIndicatorView.autoresizingMask = [.flexibleLeftMargin,
             animatedImageIndicatorView.autoresizingMask = [.flexibleLeftMargin,
                                                            .flexibleRightMargin,
                                                            .flexibleRightMargin,
                                                            .flexibleBottomMargin,
                                                            .flexibleBottomMargin,