@@ -68,6 +68,7 @@ open class LoadingButton: UIButton {
6868 case outline
6969 }
7070 // Private properties
71+ private var imageAlpha : CGFloat = 1.0
7172 private var loaderWorkItem : DispatchWorkItem ?
7273 // Init
7374 public override init ( frame: CGRect ) {
@@ -198,8 +199,11 @@ open class LoadingButton: UIButton {
198199 loaderWorkItem = DispatchWorkItem { [ weak self] in
199200 guard let self = self , let item = self . loaderWorkItem, !item. isCancelled else { return }
200201 UIView . transition ( with: self , duration: 0.2 , options: . curveEaseOut, animations: {
201- viewsToBeHidden. forEach {
202- $0? . alpha = 0.0
202+ viewsToBeHidden. forEach { view in
203+ if view == self . imageView {
204+ self . imageAlpha = 0.0
205+ }
206+ view? . alpha = 0.0
203207 }
204208 self . indicator. alpha = 1.0
205209 } ) { _ in
@@ -233,6 +237,7 @@ open class LoadingButton: UIButton {
233237 UIView . transition ( with: self , duration: 0.2 , options: . curveEaseIn, animations: {
234238 self . titleLabel? . alpha = 1.0
235239 self . imageView? . alpha = 1.0
240+ self . imageAlpha = 1.0
236241 } ) { _ in
237242 guard !item. isCancelled else { return }
238243 completion ? ( )
@@ -251,6 +256,9 @@ open class LoadingButton: UIButton {
251256 // layoutSubviews
252257 open override func layoutSubviews( ) {
253258 super. layoutSubviews ( )
259+ if let imageView = imageView {
260+ imageView. alpha = imageAlpha
261+ }
254262 indicator. center = CGPoint ( x: self . frame. size. width/ 2 , y: self . frame. size. height/ 2 )
255263 }
256264 // MARK: Touch
0 commit comments