开发者

make buttons stick to side when view rotates

I have a view where I in manually in my code add 2 buttons as subview and place them at a specific location (lower right corner).开发者_如何学运维

How do i make them "stick" to the lower right corner when the view is resized? (on rotation)

Thanks


Did you try to set the autoresizingMask of your buttons ?

button.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleTopMargin;

It assumes that the autoresizesSubviews property of the button's superview is set to YES (that is the default value)


You should implement method

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

in your UIViewController and manually change the frame of the button, changing the origin. i.e:

CGRect frame = button.frame;
frame.origin.x += 30;
frame.origin.y -= 20;

button.frame = frame;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜