开发者

Can you establish a button in IB and move it programmatically?

I have a button set up in IB. I have an IBOut开发者_运维技巧let set up and the onscreen object linked to it. Is there a way to programmatically change that buttons position and/or size? I know you can change the title and some things but I don't see how to change it's position or size.

Thank You.


You can change the frame of the button (or any UIView).

CGRect frame = [button frame];
frame.origin.x += 100;  // change the location
frame.size.width += 100;  // change the size
[button setFrame:frame];


You simply create a new frame for it i.e. myButton.frame = CGRectMake(0,0,123,412); and it moves to that new frame. The order for CGRectMake is (origin x, origin y, width, height).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜