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];
精彩评论