//
// MyPageCorol.h
// lejiahui
//
// Created by iOS开发 on 16/4/10.
// Copyright © 2016年 zhongmingwuye. All rights reserved.
// #import <UIKit/UIKit.h> @interface MyPageCorol : UIView /** 当前页数 */
@property(nonatomic,assign) NSInteger correntPage; /** itmenSize */
@property(nonatomic,assign) CGSize itmeSize; + (MyPageCorol *)myPageControlWithSuperView:(UIView *)superView; - (void)setImage:(UIImage *)image andSelectImage:(UIImage *)slectImage totalNum:(NSInteger)totalNum; - (void)setColor:(UIColor *)color andSelectColor:(UIColor*)selectColor totalNum:(NSInteger)totalNum; @end //
// MyPageCorol.m
// lejiahui
//
// Created by iOS开发 on 16/4/10.
// Copyright © 2016年 zhongmingwuye. All rights reserved.
// #import "MyPageCorol.h" @interface MyPageCorol()
{
NSMutableArray * _pageItems;
UIColor * _selectedColor;
UIColor * _color; UIImage * _image;
UIImage * _selectedImage; BOOL _isImage; NSInteger _width;
NSInteger _height;
} @end @implementation MyPageCorol + (MyPageCorol *)myPageControlWithSuperView:(UIView *)superView{
MyPageCorol * pl = [[MyPageCorol alloc]init];
pl.frame = CGRectMake(, superView.frame.size.height-, superView.frame.size.width, );
pl.backgroundColor = [UIColor clearColor];
[superView addSubview:pl];
return pl;
} - (instancetype)init{
if (self=[super init]) {
self.itmeSize = CGSizeMake(, );
}
return self;
} - (void)setItmeSize:(CGSize)itmeSize{
_itmeSize = itmeSize;
_width = itmeSize.width;
_height = itmeSize.height;
}
//设置图片形式
- (void)setImage:(UIImage *)image andSelectImage:(UIImage *)slectImage totalNum:(NSInteger)totalNum{
_isImage = YES;
_image = image;
_selectedImage = slectImage; _pageItems = [[NSMutableArray alloc]init];
NSInteger num = totalNum; NSInteger height = ;
NSInteger width =;
if (self.itmeSize.height!=&&self.itmeSize.width!=) {
height = self.itmeSize.height;
width = self.itmeSize.width;
}
NSInteger sepreate = ;
NSInteger totalWidth = num*width+(num-)*sepreate;
NSInteger orangex = (self.frame.size.width-totalWidth)/;
NSInteger orangey = (self.frame.size.height - height)/;
for (int i = ;i< num; i++) {
UIImageView * pageView = [[UIImageView alloc]init];
pageView.frame = CGRectMake(orangex+i*(width+sepreate), orangey, width, height);
[_pageItems addObject:pageView];
[self addSubview:pageView];
}
self.correntPage = ;
} //设置颜色形式
- (void)setColor:(UIColor *)color andSelectColor:(UIColor*)selectColor totalNum:(NSInteger)totalNum{
_pageItems = [[NSMutableArray alloc]init];
_color = color;
_selectedColor = selectColor; NSInteger num = totalNum;
NSInteger height = ;
NSInteger width =;
if (self.itmeSize.height!=&&self.itmeSize.width!=) {
height = self.itmeSize.height;
width = self.itmeSize.width;
}
NSInteger sepreate = ;
NSInteger totalWidth = num*width+(num-)*sepreate;
NSInteger orangex = (self.frame.size.width-totalWidth)/;
NSInteger orangey = (self.frame.size.height - height)/;
for (int i = ;i< num; i++) {
UIView * pageView = [[UIView alloc]init];
pageView.frame = CGRectMake(orangex+i*(width+sepreate), orangey, width, height);
[_pageItems addObject:pageView];
[self addSubview:pageView];
}
self.correntPage = ;
} - (void)setCorrentPage:(NSInteger)correntPage{
_correntPage = correntPage;
for (int i = ; i<_pageItems.count; i++) {
if (_isImage) {
UIImageView * imageView= _pageItems[i];
imageView.image = _image;
if (correntPage==i) {
imageView.image = _selectedImage;
}
}else{
UIView * view = _pageItems[i];
view.backgroundColor = _color;
if (correntPage==i) {
view.backgroundColor = _selectedColor;
}
}
}
} @end

最新文章

  1. C#双链表
  2. Docker 安装及命令
  3. IOS的APNS和PushKit门道详述
  4. 给网卡配置10个临时ip地址,但是不配置192.168.17.15这个ip
  5. 25.usb固件深入
  6. IOS学习网站
  7. linux - 怎么自动填写有交互的shell脚本 - SegmentFault
  8. 拥抱ARM妹子第二季 之 序:我和春天有个约会 - 生命的萌芽
  9. HDU1878欧拉回路
  10. 基于visual Studio2013解决C语言竞赛题之0612递归
  11. Python装饰器实现几类验证功能做法
  12. Jenkins具体安装与构建部署使用教程
  13. Nodejs使用redis
  14. CF 1013E Hills
  15. Spring学习笔记--Spring简介
  16. 【BZOJ-1493】项链工厂 Splay
  17. 2018.08.19 NOIP模拟 number(类数位dp)
  18. jquery on() bind()绑定的点击事件在js动态新添加的元素生效
  19. 10-19C#基础--第四部分类型(2)重点
  20. 汕头市队赛 SRM13 T3

热门文章

  1. 比较满意设计的一次作业 JDBC宠物管理
  2. 菜鸟学习笔记2,$(document).ready()使用讨论
  3. 如何添加真机调试的iOS设备
  4. 内核打上yaffs2补丁遇到的问题
  5. ecshop 点购物车弹出提示框
  6. Java核心技术II读书笔记(三)
  7. Android设计模式之策略模式
  8. OpenGL学习之路(二)
  9. Arduino运行时突然[卡死在某一行/立即重启/串口输出乱码/程序执行不正常]的可能原因
  10. PHP 截取字符串专题