- (void)loadView {
[super loadView];
self.title = @"主界面";
self.view.backgroundColor = [UIColor grayColor];
UIView * scrollBg = [[[UIView alloc] initWithFrame:CGRectMake(20, 10, 290, 400)] autorelease];
scrollBg.backgroundColor = [UIColor redColor];
scrollBg.clipsToBounds = YES; //此句话重要,裁剪到边缘
[self.view addSubview:scrollBg];
UIScrollView * _activityPlaceScl = [[[UIScrollView alloc]initWithFrame:CGRectMake(25, 10, 240, 320)] autorelease];
_activityPlaceScl.pagingEnabled = YES;
_activityPlaceScl.backgroundColor = [UIColor clearColor];
_activityPlaceScl.clipsToBounds = NO; //此句话重要,不裁剪到边缘
_activityPlaceScl.contentSize = CGSizeMake(_activityPlaceScl.frame.size.width * 5, _activityPlaceScl.frame.size.height);
_activityPlaceScl.showsHorizontalScrollIndicator = NO;
_activityPlaceScl.showsVerticalScrollIndicator = NO;
[scrollBg addSubview:_activityPlaceScl];
for (int page = 0; page < 5; page++) {
CGRect frame = _activityPlaceScl.frame;
UIButton *backgroundButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
backgroundButton.frame = CGRectMake(frame.size.width * page + 10, 0, 220, 258);
[_activityPlaceScl addSubview:backgroundButton];
}
}
网友评论