Reputation: 68750
How do I add, in code, a UIImageView to a UIScrollView so that it appears in the center.
The scroll view fills a large area, the UIImage view is about 40% the size on average.
Upvotes: 3
Views: 3326
Reputation:
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];
Upvotes: 1