iOS实现图片无限轮播之使用第三方库SDCycleScrollView(转)
下载链接:github不断更新地址:https://github.com/gsdios/SDCycleScrollView
#import "ViewController.h"
#import "SDCycleScrollView.h"
@interface ViewController () <</span>SDCycleScrollViewDelegate>
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor colorWithRed:0.98green:0.98 blue:0.98 alpha:0.99];
UIImageView *backgroundView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"005.jpg"]];
frame = self.view.bounds;
self.view addSubview:backgroundView];
// 情景一:采用本地图片实现
NSArray *images = @[[UIImage imageNamed:@"h1.jpg"],
UIImage imageNamed:@"h2.jpg"],
UIImage imageNamed:@"h3.jpg"],
UIImage imageNamed:@"h4.jpg"]
];
// 情景二:采用网络图片实现
NSArray *imagesURLStrings = @[
@"https://ss2.baidu.com/-vo3dSag_xI4khGko9WTAnF6hhy/super/whfpf=425,260,50/sign=a4b3d7085dee3d6d2293d48b252b5910/0e2442a7d933c89524cd5cd4d51373f0830200ea.jpg",
@"https://ss0.baidu.com/-Po3dSag_xI4khGko9WTAnF6hhy/super/whfpf=425,260,50/sign=a41eb338dd33c895a62bcb3bb72e47c2/5fdf8db1cb134954a2192ccb524e9258d1094a1e.jpg",
@"http://c.hiphotos.baidu.com/image/w=400/sign=c2318ff84334970a4773112fa5c8d1c0/b7fd5266d0160924c1fae5ccd60735fae7cd340d.jpg"
];
// 情景三:图片配文字
NSArray *titles = @[@"感谢您的支持,如果下载的",
@"如果代码在使用过程中出现问题",
@"您可以发邮件到gsdios@126.com",
@"感谢您的支持"
];
CGFloat w = self.view.bounds.size.width;
// 本地加载 --- 创建不带标题的图片轮播器
SDCycleScrollView *cycleScrollView = [SDCycleScrollViewcycleScrollViewWithFrame:CGRectMake(0, 100, w, 180)imagesGroup:images];
cycleScrollView.infiniteLoop = YES;
delegate = self;
cycleScrollView.pageControlStyle = SDCycleScrollViewPageContolStyleAnimated;
self.view addSubview:cycleScrollView];
// --- 轮播时间间隔,默认1.0秒,可自定义
//cycleScrollView.autoScrollTimeInterval = 4.0;
//网络加载 --- 创建带标题的图片轮播器
SDCycleScrollView *cycleScrollView2 = [SDCycleScrollViewcycleScrollViewWithFrame:CGRectMake(0, 320, w, 180)imageURLStringsGroup:nil]; // 模拟网络延时情景
cycleScrollView2.pageControlAliment =SDCycleScrollViewPageContolAlimentRight;
delegate = self;
titlesGroup = titles;
dotColor = [UIColor yellowColor]; // 自定义分页控件小圆标颜色
placeholderImage = [UIImageimageNamed:@"placeholder"];
self.view addSubview:cycleScrollView2];
模拟加载延迟
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
imageURLStringsGroup = imagesURLStrings;
});
// 清除缓存
// [cycleScrollView2 clearCache];
}
void)cycleScrollView:(SDCycleScrollView *)cycleScrollView
didSelectItemAtIndex:(NSInteger)index
NSLog(@"---点击了第%ld张图片",
index);
@end
iOS实现图片无限轮播之使用第三方库SDCycleScrollView(转)的更多相关文章
- iOS:实现图片的无限轮播之使用第三方库SDCycleScrollView
下载链接:github不断更新地址:https://github.com/gsdios/SDCycleScrollView #import "ViewController.h" # ...
- iOS开发之ImageView复用实现图片无限轮播
在上篇博客中iOS开发之多图片无缝滚动组件封装与使用给出了图片无限轮播的实现方案之一,下面在给出另一种解决方案.今天博客中要说的就是在ScrollView上贴两个ImageView, 把ImageVi ...
- iOS 两种不同的图片无限轮播
代码地址如下:http://www.demodashi.com/demo/11608.html 前记 其实想写这个关于无限轮播的记录已经很久很久了,只是没什么时间,这只是一个借口,正如:时间就像海绵, ...
- iOS开发之三个Button实现图片无限轮播(参考手机淘宝,Swift版)
这两天使用Reveal工具查看"手机淘宝"App的UI层次时,发现其图片轮播使用了三个UIButton的复用来实现的图片循环无缝滚动.于是乎就有了今天这篇博客,看到“手机淘宝”这个 ...
- Android实现广告页图片无限轮播
一.概述 对于一个联网的Android应用, 首页广告无限轮播基本已经成为标配了. 那么它是怎么实现的呢? 有几种实现方式呢? 二.无限轮播的实现 1.最常规的手段是用 ViewPager来实现 2. ...
- ViewPager—02图片无限轮播
布局文件 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:t ...
- iOS:实现图片的无限轮播(二)---之使用第三方库SDCycleScrollView
iOS:实现图片的无限轮播(二)---之使用第三方库SDCycleScrollView 时间:2016-01-19 19:13:43 阅读:630 评论:0 收藏:0 ...
- iOS:实现图片的无限轮播
为尊重原创,特注明原文链接:http://m.myexception.cn/operating-system/1949043.html 图片轮播及其无限循环效果 平时APP中的广告位或者滚动的新闻图片 ...
- iOS:实现图片的无限轮播---之使用第三方库SDCycleScrollView
SDCycleScrollView API // // SDCycleScrollView.h // SDCycleScrollView #import <UIKit/UIKit.h> ...
随机推荐
- linux下18种监测网络带宽方式
1. nload nload是一个命令行工具,让用户可以分开来监控入站流量和出站流量.它还可以绘制图表以显示入站流量和出站流量,视图比例可以调整.用起来很简单,不支持许多选项. 所以,如果你只需要快速 ...
- SmtpClient 发送邮件
利用SmtpClient 代码发送邮件. 简单测试代码: static void Main(string[] args) { MailMessage msg = new MailMessage(); ...
- 保护你的Linux系统的九个老生常谈
在现在这个世道中,保障基于Linux的系统的安全是十分重要的.但是,你得知道怎么干.一个简单反恶意程序软件是远远不够的,你需要采取其它措施来协同工作.那么试试下面这些手段吧. 1. 使用SELinux ...
- 大数据之路week05--day02(Maven安装,环境变量的配置及基本使用)
今天我们就来学习一下maven,怎么说呢,maven更像是一种管理的工具,实现的原理是使用插件. 举个例子,比如说,一个公司需要做一个项目,这个项目又分成了很多的模块,每个模块又分成了许多的业务等等, ...
- Spring-HelloSpring-IOC创建对象的方式
3.HelloSpring 思考 Hello 对象是谁创建的 ? [ hello 对象是由Spring创建的 ] Hello 对象的属性是怎么设置的 ? [hello 对象的属性是由Spring容器设 ...
- C# DocumentCompleted事件多次条用解决方案
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { ...
- 多git项目中账户的管理
每个项目配置用户名: git config user.name "your_name" git config user.email "your_email" 如 ...
- 路由器配置——基于区域的OSPF,MD5认证
一.实验目的:掌握OSPF基于区域的MD5认证 二.拓扑图: 三.具体步骤配置 (1)R1路由器配置 Router>enable Router#configure terminal Enter ...
- 【LeetCode-86】分隔链表
[题目描述] 给定一个链表和一个特定值 x,对链表进行分隔,使得所有小于 x 的节点都在大于或等于 x 的节点之前. 你应当保留两个分区中每个节点的初始相对位置. 示例: 输入: head = 1-& ...
- springboot工程打成war包
1.将pom.xml中默认的jar修改为war. <packaging>war</packaging> 2.排除SpringBoot内置的Tomcat容器. <depen ...