几行代码,您可以轻松地将横幅添加到您的应用程序中。
##Dependency SDWebImage ##如何安装? //支持 pod install,只需做: pod 'YPBanner' //如果仓库未更新,请尝试: pod "YPBanner", :git =>"https://github.com/penoty/YPBanner" ##如何使用?(需要导入 "YPBannerView.h") ###Banner Item Init YPBannerItem *item_01 = [[YPBannerItem alloc] initWithImage:[UIImage imageNamed:@"placehold.png"] data:nil]; YPBannerItem *item_02 = [[YPBannerItem alloc] initWithUrl:@"web_url" data:nil andPlaceholder:[UIImage imageNamed:@"placehold.png"]]; ...... ###默认动画 _bannerView = [[YPBannerView alloc] initWithYPBannerItems:@[item_01,item_02...]];
###设置动画类型和持续时间 _bannerView= [[YPBannerView alloc] initWithYPBannerItems:@[item_01,item_02...] animationType:YPBannerAnimationTypeCube andAnimationDuration:1.5f]; ###设置框架 //您可以使用 setFrame 或 masonry 在任何位置设置框架 //使用 setFrame: [_bannerView setFrame:...]; //使用 Masonry [_bannerView mas_makeConstraints:^(MASConstraintMaker *make) { make... }]; ###在初始化时设置框架 - (instancetype initWithFrame:(CGRect)frame andYPBannerItems:(NSArray
animationType:(YPBannerAnimationType)type andAnimationDuration:(NSTimeInterval)duration;
###YPBannerViewDelegate //如果想要有点击回调,只需实现 YPBannerViewDelegate 方法: - (void)didTapOnBannerItem:(YPBannerItem *)item; ###公共属性 #####scrollTimeInterval (类型:CGFloat)横幅自动滚动的时间间隔 #####placeholderImg (类型:UIImage *)横幅的占位图像 #####pageIndicatorTintColor (类型:UIColor)页控制器指示器的颜色 #####currentPageIndicatorColor (类型:UIColor)页控制器当前指示器的颜色 #####使用该方法设置页控制器 - (void)setPageIndicatorColor:(UIColor *)indicatorColor andCurrentPageIndicatorColor:(UIColor *)currentIndicatorColor; #####使用该方法设置动画类型和持续时间 - (void)setAnimationType:(YPBannerAnimationType)animationType andAnimationDuration:(NSTimeInterval)animationDuration;
penoty, [email protected]
YPBanner 在 MIT 许可证下可用。有关更多信息,请参阅 LICENSE 文件。