将UIVIew作为SubView添加到iPhone窗口的右下角

时间:2011-10-25 17:13:36

标签: iphone ios

目前我的UIView大小为100px宽,40px高。如果我使用

添加它

[self.view addSubView:buttonsView];

它将这个小小的UIVIew添加到iPhone屏幕的左上角。

有没有办法让它添加到右下角呢?

1 个答案:

答案 0 :(得分:11)

在添加buttonView之前,设置其“frame”属性:

一种方式:

buttonsView.frame = CGRectMake( 
 self.view.frame.size.width - buttonsView.frame.size.width,
 self.view.frame.size.height - buttonsView.frame.size.height,
 buttonsView.frame.size.width,
 buttonsView.frame.size.height );