Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions HCSStarRatingView/HCSStarRatingView.m
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ - (void)drawRect:(CGRect)rect {
CGFloat availableWidth = rect.size.width - (_spacing * (_maximumValue - 1)) - 2;
CGFloat cellWidth = (availableWidth / _maximumValue);
CGFloat starSide = (cellWidth <= rect.size.height) ? cellWidth : rect.size.height;
if (self.emptyStarImage) starSide = self.emptyStarImage.size.height;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should rely on self.shouldUseImages for this for consistency.

for (int idx = 0; idx < _maximumValue; idx++) {
CGPoint center = CGPointMake(cellWidth*idx + cellWidth/2 + _spacing*idx + 1, rect.size.height/2);
CGRect frame = CGRectMake(center.x - starSide/2, center.y - starSide/2, starSide, starSide);
Expand Down Expand Up @@ -386,8 +387,10 @@ - (BOOL)canBecomeFirstResponder {
#pragma mark - Intrinsic Content Size

- (CGSize)intrinsicContentSize {
CGFloat height = 44.f;
return CGSizeMake(_maximumValue * height + (_maximumValue-1) * _spacing, height);
CGFloat imageSide = self.emptyStarImage.size.height;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Total nitpick here, but could we call this imageHeight?

CGFloat height = MAX(44.f, imageSide);
CGFloat itemWidth = imageSide ?: height;
return CGSizeMake(_maximumValue * itemWidth + (_maximumValue-1) * _spacing, height);
}

#pragma mark - Accessibility
Expand Down