ios - setting frame in swift doesn't work as expected -
i'm porting app objective-c pure swift , i'm facing strange problem.
i've got alertview
class replacement standard uialertview
(now uialertcontroller
) displaying animatable popups. alertview
created in uiviewcontroller
extension - it's inited view controller's view frame , added subview.
alertview
has property popupview
's instance - custom uiview
subclass xib (on autolayout). popup should has dynamic height depends on contents (multiline message label).
now when i'm trying animate popup in alertview
class:
- when set in
popupview
settranslatesautoresizingmaskintoconstraints(false)
- view's height correct setting frame in animation doesn't work expected - view sticked top left corner - when set
settranslatesautoresizingmaskintoconstraints(true)
- animation works expected view has size xib (won't expand according contents)
what can wrong here?
edit showing popup method:
private func showpopup(popupview: popupview) { var beginframe = popupview.frame beginframe.origin.y = -beginframe.size.height beginframe.origin.x = self.bounds.size.width/2 - beginframe.width/2 popupview.frame = beginframe var endframe = beginframe endframe.origin.y = self.bounds.size.height/2 - endframe.size.height/2 popupview.hidden = false dlog(beginframe) uiview.animatewithduration(kanimationtime, delay: 0, usingspringwithdamping: kanimationdamping, initialspringvelocity: kanimationspringvelocity, options: uiviewanimationoptions.curveeasein, animations: { () -> void in dlog(endframe) popupview.frame = endframe }, completion: nil) }
in both cases shows in console:
(72.5, -155.0, 230.0, 155.0)
(72.5, 256.0, 230.0, 155.0)
edit2
settranslatesautoresizingmaskintoconstraints(false)
settranslatesautoresizingmaskintoconstraints(true)
ok, got solution. i've stopped mixing autolayout , direct frame modifications , use pure autolayout instead.
Comments
Post a Comment