开发者

How is the location of a subView set?

I am using the standard facebook connect butto开发者_运维技巧n with the method

FBLoginButton *loginButton = [[[FBLoginButton alloc] init] autorelease];
[self.view addSubview: loginButton];

and It places it where I dont want it. How can I set that subviews location?


Access the view's frame property:

loginButton.frame = CGRectMake(originX, originY, sizeWidth, sizeHeight);


You set a view's origin relative to their parent view using setFrameOrigin:

NSPoint origin = NSMakePoint(0,0);
FBLoginButton *loginButton = [[[FBLoginButton alloc] init] autorelease];
[loginButton setFrameOrigin:origin];
[self.view addSubview: loginButton];


Like every other UIView, you can use its frame property to specify its size and position.

You can also use the center property to just reposition the control.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜