开发者

UIScrollView - Add Subview so that it's centered Horizontal and Vertical

How do I add, in code, a UIImageView to a UISc开发者_运维技巧rollView so that it appears in the center.

The scroll view fills a large area, the UIImage view is about 40% the size on average.


How about imageView.center = scrollView.center


What about something around the lines of...

int size = 20;

UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];

UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake((scrollView.center.x - (size / 2)), (scrollView.center.y - (size / 2)), size, size)];

[scrollView addSubview:imageView];
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜