OC Control FHXAnimationProgress(進度條)
阿新 • • 發佈:2021-02-13
技術標籤:UI的封裝iosobjective-cswiftxcode
一直覺得自己寫的不是技術,而是情懷,一個個的教程是自己這一路走來的痕跡。靠專業技能的成功是最具可複製性的,希望我的這條路能讓你們少走彎路,希望我能幫你們抹去知識的蒙塵,希望我能幫你們理清知識的脈絡,希望未來技術之巔上有你們也有我。
今天是2021年春節 初一 祝大家春節快樂
提供的方法
#pragma mark --- Configuring Progress
/**
進度 atomic 原子性,
*/
@property (atomic, assign)CGFloat progress;
/**
設定進度
@param progress 進度
@param animated 是否需要動畫
*/
- (void)setProgress:(CGFloat)progress animated:(BOOL)animated;
/**
進度條顏色陣列,多組顏色會設定成漸變色
設定該屬性後, 屬性progressTintColor將會失效
*/
@property (nonatomic, strong) NSArray *progressTintColors;
/**
進度條顏色
default is view backgroundColor.
*/
@property (nonatomic, strong)UIColor *progressTintColor;
/**
進度條是否內嵌
default is 0.
*/
@property (nonatomic, assign)CGFloat progressViewInset;
/**
圓角
default is half of height.
*/
@property (nonatomic, assign)CGFloat progressCornerRadius;
#pragma mark --- Configuring Stripes
/**
條紋是否運動
defau is NO.
*/
@property (nonatomic, getter = isStripesAnimated)BOOL stripesAnimated;
/**
條紋運動位移
default is 1
*/
@property (nonatomic, assign)double stripesAnimationVelocity;
/**
條紋傾斜方向
default is LRStripesOrientationRight
*/
@property (nonatomic, assign)LRStripesOrientation stripesOrientation;
/**
條紋寬度
default is 10.0f
*/
@property (nonatomic, assign)NSInteger stripesWidth;
/**
條紋顏色
default is purple color
*/
@property (nonatomic, strong)UIColor *stripesColor;
/**
條紋的傾斜角度
default is 5.0f
*/
@property (nonatomic, assign)NSInteger stripesDelta;
/**
是否隱藏條紋
default is NO
*/
@property (nonatomic, assign)BOOL hideStripes;
#pragma mark --- Configuring Track
/**
是否隱藏軌跡
default is NO
*/
@property (nonatomic, assign)BOOL hideTrack;
/**
軌跡顏色
default is black color
*/
@property (nonatomic, strong)UIColor *trackTintColor;
#pragma mark --- Configuring Node
/**
節點個數
you can set number of nodes between 2 and 5.
*/
@property (nonatomic, assign)NSInteger numberOfNodes;
/**
節點顏色
default is track tint color.
if no track tint color,you need set a color.
*/
@property (nonatomic, strong)UIColor *nodeColor;
/**
節點高亮顏色
node had been selected.
default is progress tint color.
if no progress tint color, you need set a color.
*/
@property (nonatomic, strong)UIColor *nodeHighlightColor;
/**
節點周圍的圓環效果
default is YES.
*/
@property (nonatomic, assign)BOOL hideAnnulus;
- (instancetype)initWithFrame:(CGRect)frame;
使用
//進度條的使用要封裝多一個view才能夠使用,不然用frame約束會出錯。
@property (nonatomic,strong) FHXAnimationProgress *progressView;
self.progressView = [FHXAnimationProgress new];
self.progressView.addTo(self.view);
self.progressView.makeCons(^{
make.left.equal.view(self.view).constants(15);
make.bottom.equal.view(self.view).constants(-20);
make.height.equal.constants(10);
make.width.equal.constants(200);
});
// self.progressView.frame = CGRectMake(5, self.view.frame.size.height-10-10, self.view.frame.size.width-70-15-10, 12);
self.progressView.backgroundColor = [UIColor clearColor];
self.progressView.layer.cornerRadius = 5;
self.progressView.layer.masksToBounds = YES;
self.progressView.progressTintColors = @[LRColorWithRGB(0xce2b2c),LRColorWithRGB(0xff734d)];
//動畫節條
self.progressView.stripesWidth = 10;
//是否開啟動畫
self.progressView.stripesAnimated = YES;
//YES漸變效果 NO折條效果
self.progressView.hideStripes = NO;
//節點個數
self.progressView.numberOfNodes = 0;
self.progressView.hideAnnulus = NO;
//yes 已動畫的形式遞進(脹滿) NO沒有動畫 最好設定NO 防止重複重新整理滾動條重複載入
[self.progressView setProgress:0.5 animated:NO];