iOS SDK: Moving the button into the center of screen by code

前端 未结 6 1679

I want to move a button to the center of the screen by code. I saw somewhere it is just few lines of code, but could not find them.

6条回答
  •  鱼传尺愫
    2021-01-05 01:48

    Both rooster117 and DavidNg answers seem correct. Just to add one more "option" to you, if you want to do this animated, you should do:

    NSTimeInterval seconds = 1.0;
    [UIView animateWithDuration:seconds animations:^{
        //here you should write any reframing/repositioning code
    }];
    

提交回复
热议问题