Ratingview star comment Control Learning for iOS open-source Project (1)

Source: Internet
Author: User
1 Preface

During this time, I learned the basic things of iOS, and the theory needs to be related to the actual situation. I do not want to look for several open-source project codes for research. I am suffering from technical limitations, at the beginning, we can only research and write simple controls. Today we will learn a simple control application, star rating control.

2. Details

This is a very simple control, but not a lot of it is used, so it is good as an entry-level learning material.

Directory structure:


Code Overview:

Ratingcontrollerviewcontroller. h

#import <UIKit/UIKit.h>#import "ZYRatingView.h"@interface ZYViewController : UIViewController<RatingViewDelegate>{ZYRatingView *starView;UILabel *ratingLabel;}@property (nonatomic, retain) IBOutlet ZYRatingView *starView;@property (nonatomic, retain) IBOutlet UILabel *ratingLabel;-(IBAction)clearRating:(id)sender;-(void)ratingChanged:(float)newRating;@end

Ratingcontrollerviewcontroller. m

-(Void) viewdidload {[Super viewdidload]; nslog (@ "Initializing rating View"); // initialize the rating view. The proxy is viewcontroller [starview setimagesdeselected: @ "0.png" partlyselected: @ "1.png" fullselected: @" 2.png" anddelegate: Self]; // set the score [starview displayrating: 1.5];} // clear the score-(ibaction) clearrating :( ID) sender {[starview displayrating: 0.0];} // implement proxy method-(void) ratingchanged :( float) newrating {// display ratinglabel. TEXT = [nsstring stringwithformat: @ "rating is: % 1.1f", newrating];}

If you want to view the complete code, click the link at the end of the article to download the code, which comes with your own comprehensive Chinese comments for your convenience.

Running result:


Click the score control.


Click Clear.



3 conclusion

The above is all content and I hope it will help you.

Demo: http://download.csdn.net/detail/u010013695/5428683

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.