Thanks a lot! Please help!
I hava a scrollView in a UIView and a imageView in the ScrollView. they have same size. and here are the LOGs of the scrollView and imageview
and I have not used autoLayout constrains between uiview and scroll View as well as scrollview and UIimageView
the code are:
- (void)setupScrollView
{
CGRect frame = CGRectMake(0, 0, self.scrollViewSizeView.frame.size.width, self.scrollViewSizeView.frame.size.height);
_colorScrollView = [[ColorScrollView alloc]initWithFrame:frame andUIImage:self.image];
[self.scrollViewSizeView addSubview:self.colorScrollView];
}
- (instancetype)initWithFrame:(CGRect)frame andUIImage:(UIImage *)image
{
self = [super initWithFrame:frame];
if (self)
{
self.contentSize = frame.size;
_imageView = [[ColorImageView alloc]initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)];
self.imageView.image = image;
[self addSubview:self.imageView];
}
return self;
}
scrollView:
<ColorScrollView: 0x7fee13746dc0; baseClass = UIScrollView; frame = (0 0; 600 436); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x7fee13748270>; layer = <CALayer: 0x7fee13741330>; contentOffset: {0, 0}; contentSize: {600, 436}>
imageView:
<ColorImageView: 0x7fee13747e00; baseClass = UIImageView; frame = (0 0; 600 436); opaque = NO; layer = <CALayer: 0x7fee1370fc50>>
the imageView content mode is UIViewContentModeScaleAspectFit. I want the image in imageView is center. but it is not. it look like it prefer to stay at the right side. sorry that I don't have enough reputation to post a image:
it looks this (* means transparent)
*****this is the image area
*****this is the image area
*****this is the image area
*****this is the image area
*****this is the image area