Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
changsanjiang committed Aug 25, 2017
1 parent dffb5e1 commit 92a95fa
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 4 deletions.
2 changes: 1 addition & 1 deletion SJSlider.podspec
@@ -1,7 +1,7 @@

Pod::Spec.new do |s|
s.name = 'SJSlider'
s.version = '0.0.3'
s.version = '0.0.4'
s.summary = 'Slide view with buffer / slide / progress.'
s.description = 'https://github.com/changsanjiang/SJSlider/blob/master/README.md'
s.homepage = 'https://github.com/changsanjiang/SJSlider'
Expand Down
6 changes: 5 additions & 1 deletion SJSlider/SJSlider.h
Expand Up @@ -12,6 +12,11 @@

@interface SJSlider : UIView

/*!
* default is YES.
*/
@property (nonatomic, assign, readwrite) BOOL isRound;

/*!
* 轨道
* this is view, If you don't want to set up photos, You can set the background color.
Expand Down Expand Up @@ -85,7 +90,6 @@
/*!
* borderColor
* default is lightGrayColor.
* if you don't want it, you can set it to clearColor.
*/
@property (nonatomic, strong, readwrite) UIColor *borderColor;

Expand Down
22 changes: 20 additions & 2 deletions SJSlider/SJSlider.m
Expand Up @@ -68,7 +68,12 @@ - (CGFloat)csj_h {



@interface SJContainerView : UIView @end
@interface SJContainerView : UIView
/*!
* default is YES.
*/
@property (nonatomic, assign, readwrite) BOOL isRound;
@end

@implementation SJContainerView

Expand All @@ -87,7 +92,14 @@ - (void)_SJContainerViewSetupUI {

- (void)layoutSubviews {
[super layoutSubviews];
self.layer.cornerRadius = MIN(self.csj_w, self.csj_h) * 0.5;
if ( _isRound ) self.layer.cornerRadius = MIN(self.csj_w, self.csj_h) * 0.5;
else self.layer.cornerRadius = 0;
}

- (void)setIsRound:(BOOL)isRound {
_isRound = isRound;
if ( _isRound ) self.layer.cornerRadius = MIN(self.csj_w, self.csj_h) * 0.5;
else self.layer.cornerRadius = 0;
}

@end
Expand Down Expand Up @@ -197,6 +209,11 @@ - (instancetype)initWithFrame:(CGRect)frame {

// MARK: Setter

- (void)setIsRound:(BOOL)isRound {
_isRound = isRound;
_containerView.isRound = isRound;
}

- (void)setTrackHeight:(CGFloat)trackHeight {
_trackHeight = trackHeight;
[self.containerView mas_updateConstraints:^(MASConstraintMaker *make) {
Expand Down Expand Up @@ -227,6 +244,7 @@ - (void)_SJSliderInitialize {
self.maxValue = 1.0;
self.borderWidth = 0.4;
self.borderColor = [UIColor lightGrayColor];
self.isRound = YES;

self.enableBufferProgress = NO;
self.bufferProgress = 0;
Expand Down
Binary file not shown.
7 changes: 7 additions & 0 deletions SJSliderProjectFile/SJSlider/ViewController.m
Expand Up @@ -43,6 +43,10 @@ - (void)viewDidLoad {
slider.traceImageView.image = [UIImage imageNamed:@"progress"];
slider.thumbImageView.image = [UIImage imageNamed:@"thumb"];

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
slider.isRound = NO;
});

slider;
});

Expand All @@ -66,14 +70,17 @@ - (void)viewDidLoad {
slider.visualBorder = YES;
slider.borderColor = [UIColor redColor];
slider.borderWidth = 2;
slider.isRound = NO;

/// hidden border line.
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
slider.visualBorder = NO;
slider.isRound = YES;

/// show
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
slider.visualBorder = YES;
slider.isRound = NO;
});

});
Expand Down

0 comments on commit 92a95fa

Please sign in to comment.