wns9778.com_威尼斯wns.9778官网

热门关键词: wns9778.com,威尼斯wns.9778官网
wns9778.com > 计算机教程 > APP评价(星星点赞)很简单,app星星

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

浏览次数:70 时间:2019-11-24

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

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

我用的是storyboard

wns9778.com 1

记得一定要设置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];

            }

wns9778.com,        }

 

 

}

这样就ok 了

效果如下

wns9778.com 2

 

http://www.bkjia.com/IOSjc/1139922.htmlwww.bkjia.comtruehttp://www.bkjia.com/IOSjc/1139922.htmlTechArticleAPP评价(星星点赞)很简单,app星星 1.用代码或者storyboard创建5个button(现在一般都是5个星星) 我用的是storyboard 记得一定要设置button的...

        

    NSArray * starArray;

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

    

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

- (void)viewDidLoad {

wns9778.com 3

            }

{

            else

 

 

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

{

我用的是storyboard

- (IBAction)btn:(id)sender;

 

 

    

            {

        {

    [super didReceiveMemoryWarning];

wns9778.com 4

    UIButton * allBtn =sender;

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

 

然后在.m中 

 

            }

本文由wns9778.com发布于计算机教程,转载请注明出处:APP评价(星星点赞)很简单,app星星

关键词: wns9778.com

上一篇:使用AJAX返回WebService里的集合具体实现【wns9778.

下一篇:没有了