TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Apr 2016 |
Maintained by cwxatlm.
1.2.3 增加支持竖直滚动 //support Vertical scroll
MXScrollView
folder into your project. 把MXScrollView
文件夹拖入工程Targets->Build Phases->Copy Bundle Resources
.#imprort "MXScrollView.h"
有两种使用方式 you can use it in two ways
MXImageScrollView *scroll = [[MXIMageScrollView alloc] initWithFrame:CGRectMake(x, y, scrollWidth, scrollHeight)];
//数组支持传入image或imageUrl support image or imageUrl
scroll.images = @[
[UIImage imageNamed:@"picture_one"],
[UIImage imageNamed:@"picture_two"],
[UIImage imageNamed:@"picture_three"],
@"http://pic31.nipic.com/20130624/8821914_104949466000_2.jpg"
];
scroll.animotionType = kMXTransitionRandom; //支持多特效 support serveral type
scroll.animotionDirection = kMXTransitionDirectionRandom; //支持多方向 support serveral direction
[self.view addSubview:scroll];
[scroll setTapImageHandle:^(NSInteger index) {
//支持点击事件 support tap
}];
//在你不需要的时候释放他 例如 release the timer
- (void)viewWillDisappear:(BOOL)animated {
[scroll invalidateTimer];
}
此时必须写为全局变量
_scroll = [[MXImageScrollView alloc] initWithFrame:CGRectMake(0,
0,
CGRectGetWidth(self.view.bounds),
MXScrollViewHeight)
rootTableView:_tableView];
_scroll.animotionDirection = kMXTransitionDirectionRandom;
_scroll.animotionType = kMXTransitionRandom;
_scroll.pageControlPosition = kMXPageControlPositionCenter; //更改pageControl显示的位置
_scroll.images = @[
[UIImage imageNamed:@"picture_one"],
[UIImage imageNamed:@"picture_two"],
[UIImage imageNamed:@"picture_three"],
@"http://pic31.nipic.com/20130624/8821914_104949466000_2.jpg"
];
[_scroll setTapImageHandle:^(NSInteger index) {
//tap
}];
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
#warning 重要,想拉伸必须实现此方法 must implement this method
[_scroll stretchingImage];
}
//在你不需要的时候释放他 例如 release the timer
- (void)viewWillDisappear:(BOOL)animated {
[_scroll invalidateTimer];
}
_scroll.delegate = self;
//delegate method 给图片增加副视图
- (UIView *)MXScrollView:(MXScrollView *)mxScrollView viewForImageLeftAccessoryViewAtIndex:(NSInteger)index {
UILabel *leftLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 150, 50, 20)];
leftLabel.backgroundColor = [UIColor clearColor];
leftLabel.textColor = [UIColor whiteColor];
leftLabel.text = [NSString stringWithFormat:@"第%ld页", index];
return leftLabel;
}
//视图拉伸效果
- (UIViewAutoresizing)MXScrollView:(MXScrollView *)mxScrollView leftAccessoryViewAutoresizingMaskAtIndex:(NSInteger)index {
switch (index) {
case 0:
return UIViewAutoresizingFlexibleBottomMargin;
break;
default:
return UIViewAutoresizingFlexibleTopMargin;
break;
}
}