开发者

make buttons stick to side when view rotates

开发者 https://www.devze.com 2023-04-05 08:12 出处:网络
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).开发者_如何学运维

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

精彩评论

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