addSubview animation

前端 未结 6 886
情书的邮戳
情书的邮戳 2020-11-28 01:58

I have main UIView where I display different data. Then I put a button, which displays subview like this:

- (IBAction) buttonClicked:(id)sender
{
    UIView          


        
6条回答
  •  一生所求
    2020-11-28 02:25

    Let's do this in swift.

    var redView = UIView(frame:CGRectMake(20,20,100,100))
    redView.backgroundColor = UIColor.redColor
    redView.alpha = 0.0
    view.addSubview(redView)
    
    UIView.animateWithDuration(0.25) { () -> Void in
        redView.alpha = 1.0
    }
    

    Adding a subview cannot be animated by simply putting it in an animateWithDuration block. And it can't be animated using hidden.

提交回复
热议问题