星空网 > 软件开发 > 操作系统

APP评价(星星点赞)很简单

1.用代码或者storyboard创建5个button(现在一般都是5个星星)

我用的是storyboard

APP评价(星星点赞)很简单images/loading.gif' data-original="http://images2015.cnblogs.com/blog/858723/201607/858723-20160705153236342-1289572693.png" />

记得一定要设置button的tag值

在.h中

@property (weak, nonatomic) IBOutlet UIButton *btn5;

 

- (IBAction)btn:(id)sender;

@property (weak, nonatomic) IBOutlet UIButton *btn4;

@property (weak, nonatomic) IBOutlet UIButton *btn3;

@property (weak, nonatomic) IBOutlet UIButton *btn2;

@property (weak, nonatomic) IBOutlet UIButton *btn1;

然后在.m中 

@interface ViewController ()

{

    NSArray * starArray;

    

}

@end

 

@implementation ViewController

 

- (void)viewDidLoad {

    [super viewDidLoad];

    

    starArray = [NSArray arrayWithObjects:_btn1,_btn2,_btn3,_btn4,_btn5, nil];

    

}

 

- (void)didReceiveMemoryWarning {

    [super didReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}

 

- (IBAction)btn:(id)sender

{

    UIButton * allBtn =sender;

    for (UIButton *button in starArray)

        {

            if (button.tag <= allBtn.tag)

            {

                [button setBackgroundImage:[UIImage imageNamed:@"goldstar1"] forState:UIControlStateNormal];

        

             //  goldstar1 和 greystar2 图片名称

            }

            else

            {

                [button setBackgroundImage:[UIImage imageNamed:@"greystar2"] forState:UIControlStateNormal];

            }

        }

 

 

}

这样就ok 了

效果如下

APP评价(星星点赞)很简单

 




原标题:APP评价(星星点赞)很简单

关键词:

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

跨境小白须知:跨境电商做什么产品好?:https://www.ikjzd.com/articles/112278
考拉海购强势入驻阿里后首次开启盛大招商模式!:https://www.ikjzd.com/articles/112279
震惊!亚马逊2年删除3万+review:其中技术与家具类两个热门品类删得最狠!:https://www.ikjzd.com/articles/11228
做跨境电商,这些运营知识你需要熟记!:https://www.ikjzd.com/articles/112280
这个旺季,发FBA要注意些什么?:https://www.ikjzd.com/articles/112281
如何从买家角度优化亚马逊Listing?:https://www.ikjzd.com/articles/112283
无锡旅游景点竹海 - 无锡的竹海:https://www.vstour.cn/a/363178.html
5月贾汪好玩的地方 贾汪哪有好玩的地方:https://www.vstour.cn/a/363179.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流