Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
105 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
@import UIKit; | ||
|
||
@interface LabeledSlider : UISlider | ||
|
||
@property (nonatomic) UILabel *label; | ||
|
||
- (NSString *)labelText; | ||
- (UIColor *)labelTextColor; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
|
||
#import "LabeledSlider.h" | ||
|
||
@implementation LabeledSlider | ||
|
||
- (instancetype)initWithCoder:(NSCoder *)aDecoder; | ||
{ | ||
if (!(self = [super initWithCoder:aDecoder])) return nil; | ||
|
||
self.label = UILabel.new; | ||
self.label.textAlignment = NSTextAlignmentCenter; | ||
self.label.font = [UIFont fontWithName:@"AvenirNextCondensed-Medium" size:17.f]; | ||
self.label.adjustsFontSizeToFitWidth = YES; | ||
self.label.baselineAdjustment = UIBaselineAdjustmentAlignCenters; | ||
[self addSubview:self.label]; | ||
|
||
return self; | ||
} | ||
|
||
- (void)layoutSubviews; | ||
{ | ||
[super layoutSubviews]; | ||
[self bringSubviewToFront:self.label]; | ||
self.label.frame = CGRectInset([self thumbRectForBounds:self.bounds trackRect:[self trackRectForBounds:self.bounds] value:self.value], 4.f, 0.f); | ||
self.label.text = self.labelText; | ||
self.label.textColor = self.labelTextColor; | ||
} | ||
|
||
- (NSString *)labelText; | ||
{ | ||
return [NSString stringWithFormat:@"%i", (int)roundf(self.value)]; | ||
} | ||
|
||
- (UIColor *)labelTextColor; | ||
{ | ||
return UIColor.darkGrayColor; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters