SwiftEntryKit icon indicating copy to clipboard operation
SwiftEntryKit copied to clipboard

Animated update frame

Open Banck opened this issue 6 years ago • 13 comments

Describe the bug There is an issue in SwiftEntryKit with animated updating frame of alert. For example if my attribute has attributes.positionConstraints.size = .init(width: .fill, height: .intrinsic) and then increase height of some view inside my alert view like:

someViewHeightConstraint.constant += 80
UIView.animate(withDuration: 0.3) {
         self.layoutIfNeeded()
}

superView will increase height instantly although alert view will be animated.

Screenshots If applicable, add screenshots to help explain your problem.

iPhone (please complete the following information):

  • Device: Any
  • iOS Version: tested on iOS 12
  • Xcode Version 10.2
  • SwiftEntryKit Release # 1.0

Screenshots / Video Links Sent video to your email.

Banck avatar Apr 11 '19 09:04 Banck

You should replace self.layoutIfNeeded() with SwiftEntryKit.layoutIfNeeded().

huri000 avatar Apr 11 '19 09:04 huri000

Thanks. Yes, with SwiftEntryKit.layoutIfNeeded() it works, but with SwiftEntryKit.layoutIfNeeded() there is another issue, with safe area now. Attribute has:

        attributes.entryBackground = .color(color: someColor)
        attributes.positionConstraints.safeArea = .empty(fillSafeArea: true)

and when alert decrease height safe area is blinking. (sent video to your email.)

Banck avatar Apr 11 '19 09:04 Banck

Oh, it's not related safe area. On iPhone 7 the same issue with bottom blank space.

Banck avatar Apr 11 '19 09:04 Banck

@huri000 Hello! Sorry to disturb you, but have you had a chance to look at this issue? (with bottom blank space when view is decreasing height.) Thank you so much

Banck avatar Apr 12 '19 08:04 Banck

Hi @Banck. No. Couldn't reproduce it. I suspect that this is your view's constraints colliding with the framework. If you are were able to send me a reproducible sample project, it would be helpful.

huri000 avatar Apr 12 '19 09:04 huri000

Strange, because if set entryBackground to clear and set background color to my view - everything is fine

Banck avatar Apr 12 '19 09:04 Banck

View is like: UIVIew: -UILabel -UIView (dynamic height) -UILabel

and all subview has vertical space to each other and we increase, decrease height of UIView (dynamic height)

Banck avatar Apr 12 '19 09:04 Banck

@huri000 finally, I found where is an issue. If set roundCorners EntryKit does something like that:

let path = UIBezierPath(roundedRect: self.bounds, byRoundingCorners: corners, cornerRadii: CGSize(width: radius, height: radius))
      let mask = CAShapeLayer()
      mask.path = path.cgPath
      layer.mask = mask

and when height was decreased, mask bounds wasn't. Seems this is the reason

If remove roundCorners everything is fine.

Banck avatar Apr 12 '19 09:04 Banck

I've looked at your code, saw that you call applyFrameStyle in layoutSubviews. So seems that's not the reason, but if set roundCorners to .none, everything is fine.

Banck avatar Apr 15 '19 05:04 Banck

@huri000 Hello! Here is a sample project EntryDemo.zip

Banck avatar Apr 22 '19 14:04 Banck

Thanks, @Banck! I'll investigate and let you know of any findings.

huri000 avatar Apr 22 '19 14:04 huri000

Hey, have you had a chance to consider this issue? Thank you!

Banck avatar Apr 25 '19 12:04 Banck