类似京东淘宝的五星评级,需要的看一下,找找思路
2015-11-13 10:08
459 查看
类似京东淘宝的五星评级,需要的看一下,找找思路
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[self setButton];
}
-(void)setButton
{
}
-(void)starClicked:(UIButton *)sender
{
//我们只是 设置了背景色,可以换成是梗概背景图片>>>[button setBackgroundImage:<#(UIImage *)#> forState:<#(UIControlState)#>];
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[self setButton];
}
-(void)setButton
{
buttonArray=[[NSMutableArray alloc]init];//一个全局变量 自行设置 for (NSInteger i=0; i<5; i++) { UIButton *star=[[UIButton alloc]initWithFrame:CGRectMake(52*i, 100, 50, 50)]; star.tag=i; star.backgroundColor=[UIColor whiteColor]; star.clipsToBounds=YES; //大家用的时候删掉下面三行 换成设置默认图片(未选定状态的) star.layer.cornerRadius=star.frame.size.width/2; star.layer.borderColor=[UIColor redColor].CGColor; star.layer.borderWidth=1; [star addTarget:self action:@selector(starClicked:) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:star]; [buttonArray addObject:star]; }
}
-(void)starClicked:(UIButton *)sender
{
//我们只是 设置了背景色,可以换成是梗概背景图片>>>[button setBackgroundImage:<#(UIImage *)#> forState:<#(UIControlState)#>];
for (NSInteger i=0; i<=sender.tag; i++) { [(UIButton*)buttonArray[i] setBackgroundColor:[UIColor redColor]]; } for (NSInteger j=4; j>sender.tag; j--) { [(UIButton*)buttonArray[j] setBackgroundColor:[UIColor whiteColor]]; }
}
相关文章推荐
- CocoaPods安装和使用教程
- 获取listview渲染后的高度
- Unsupported compiler 'GCC 4.2' selected for architecture 'i386'
- iOS之应用程序国际化
- 如何学习数字信号处理?——数字信号处理学习方法及学习资料( 原创,若转载请标明出处 )
- 窄巷道托盘货架(VNA)介绍
- 关于CocoaPods详解
- 常见CSS注意问题
- svn:is not under version control and is not part of the commit, yet its child '
- iOS Animations
- Android 将程序从后台转到前台
- 从源代码剖析Mahout推荐引擎
- CXF与Spring的结合
- iOS 精益编程
- JavaScript中的setInterval用法
- php的一些代码分页!
- 数据结构、算法与应用 (C++描述) 第二版 1.4
- Java 接口和抽象类区别
- C++基础:: struct vs class
- oc与swift混编,OC调用swift,swift调用OC