- add scroll
- scroll add contentView
- contentView add anyView
/** viewScroll */
@property (nonatomic, strong) UIScrollView *viewScroll;
/** 自动布局的目标view 在此view 上添加anyView 进行约束 */
@property (nonatomic, strong) UIView *viewContent;
#pragma mark INIT ------------ initViewShareImage
- (void)initViewShareImage {
[self.view addSubview:self.viewScroll];
[self.viewScroll mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.view).with.insets(UIEdgeInsetsMake(0, 0, 0, 0));
}];
[self.viewScroll addSubview:self.viewContent];
self.viewContent.backgroundColor = COLOR_BLUE;
[self.viewContent mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.viewScroll).with.insets(UIEdgeInsetsMake(0, 0, 0, 0));
make.width.equalTo(self.viewScroll);//和viewScroll等宽
}];
[self.viewContent addSubview:anyView];
}
#pragma mark LAZY ------------ viewScroll
- (UIScrollView *)viewScroll {
if (_viewScroll == nil) {
_viewScroll = [[UIScrollView alloc] init];
_viewScroll.contentSize = self.view.size;
_viewScroll.backgroundColor = [UIColor whiteColor];
_viewScroll.delegate = self;
_viewScroll.bounces = NO;
_viewScroll.pagingEnabled = YES;
_viewScroll.showsVerticalScrollIndicator = YES;
_viewScroll.showsHorizontalScrollIndicator = NO;
}
return _viewScroll;
}
#pragma mark LAZY ------------ viewContent
- (UIView *)viewContent {
if (_viewContent == nil) {
_viewContent = [[UIView alloc] init];
}
return _viewContent;
}