五星评论、展示评论星级支持小数

好像第二次写这个星星的评论了,索性就抽取一个算了,免得下次又搞。

这次也考虑到了小数的展示,比如说4.3、2.5这样的评分展示。

主要运用了的CAlayer的contentsRect属性来展示小数部分。

/* A rectangle in normalized image coordinates defining the
 * subrectangle of the `contents' property that will be drawn into the
 * layer. If pixels outside the unit rectangles are requested, the edge
 * pixels of the contents image will be extended outwards. If an empty
 * rectangle is provided, the results are undefined. Defaults to the
 * unit rectangle [0 0 1 1]. Animatable. */

@property CGRect contentsRect;

效果如下: 如图

具体的代码见github:https://github.com/y500/RateStarView