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
4 changes: 1 addition & 3 deletions HMSegmentedControl/HMSegmentedControl.m
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,6 @@ - (CGSize)measureTitleAtIndex:(NSUInteger)index {
if ([title isKindOfClass:[NSString class]] && !self.titleFormatter) {
NSDictionary *titleAttrs = selected ? [self resultingSelectedTitleTextAttributes] : [self resultingTitleTextAttributes];
size = [(NSString *)title sizeWithAttributes:titleAttrs];
UIFont *font = titleAttrs[@"NSFont"];
size = CGSizeMake(ceil(size.width), ceil(size.height-font.descender));
} else if ([title isKindOfClass:[NSString class]] && self.titleFormatter) {
size = [self.titleFormatter(self, title, index, selected) size];
} else if ([title isKindOfClass:[NSAttributedString class]]) {
Expand Down Expand Up @@ -323,7 +321,7 @@ - (void)drawRect:(CGRect)rect {
BOOL locationUp = (self.selectionIndicatorLocation == HMSegmentedControlSelectionIndicatorLocationUp);
BOOL selectionStyleNotBox = (self.selectionStyle != HMSegmentedControlSelectionStyleBox);

CGFloat y = roundf((CGRectGetHeight(self.frame) - selectionStyleNotBox * self.selectionIndicatorHeight) / 2 - stringHeight / 2 + self.selectionIndicatorHeight * locationUp);
CGFloat y = (CGRectGetHeight(self.frame) - selectionStyleNotBox * self.selectionIndicatorHeight) / 2 - stringHeight / 2 + self.selectionIndicatorHeight * locationUp;
CGRect rect;
if (self.segmentWidthStyle == HMSegmentedControlSegmentWidthStyleFixed) {
rect = CGRectMake((self.segmentWidth * idx) + (self.segmentWidth - stringWidth) / 2, y, stringWidth, stringHeight);
Expand Down