IOS 圓形進度條

2021-09-07 14:09:31 字數 3882 閱讀 3569

//

//demo

////

created by leao on 2017/8/7.

////

#import

typedef ns_enum(nsinteger, ccprogressviewstyle) ;

@inte***ce

ccprogressview : uiview

@property(nonatomic, assign, setter=setprogress:) cgfloat progress; //

0.0 ~ 1.0

@property(nonatomic, assign) ccprogressviewstyle progressviewstyle;

//進度條style

@property(nonatomic, strong) uicolor *tracktintcolor; //

進度條背景色

@property(nonatomic, strong) uicolor *progresstintcolor; //

進度條顏色

@property(nonatomic, strong) uicolor *progressfulltintcolor; //

進度完成時progresstint的顏色

@property(nonatomic, assign) cgfloat linewidth; //

繪製progress寬度 default: 10

@property(nonatomic, assign) cgfloat trackerwidth; //

繪製progress寬度 default: 10

//ccprogressviewstylecircle 有效

@property(nonatomic, strong) uicolor *fillcolor; //

中心顏色

@property(nonatomic, assign) bool clockwise; //

是否是順時針 default: yes

@property(nonatomic, assign) cgfloat startangle; //

進度條開始angle, default: -m_pi/2.0

@property (nonatomic, strong) uibutton *centerbtn; //

記錄進度的label

@property (nonatomic, strong) uicolor *labelbackgroundcolor; //

label的背景色 預設clearcolor

@property (nonatomic, strong) uicolor *textcolor; //

label的字型顏色 預設黑色

@property (nonatomic, strong) uifont *textfont; //

label的字型大小 預設15

- (void

)setprogress:(cgfloat)progress;

- (void

)setprogress:(cgfloat)progress animated:(bool)animated;

@end

//

//demo

////

created by leao on 2017/8/7.

////

#import

"ccprogressview.h

"#import

#import

#import

#define kccprogressfillcolor [uicolor clearcolor]

#define kccprogresstintcolor rgbcolor(214, 88, 45)

#define kcctracktintcolor rgbcolor(243, 212, 187)

#define progress_width self.frame.size.width

#define progress_height self.frame.size.height

#define kanimtimeinterval 2

@inte***ce

ccprogressview ()

@property(nonatomic, strong) cashapelayer *tracklayer;

@property(nonatomic, strong) cashapelayer *progresslayer;

@end

@implementation

ccprogressview

-(instancetype)initwithframe:(cgrect)frame

return

self;

}-(instancetype)init

return

self;

}#pragma mark - private

- (void

)initsubviews

- (void

)layoutsubviews

#pragma mark - private

- (uibutton *)centerbtn

return

_centerbtn;

}- (void

)updatelayerpath

else

}#pragma mark - setter

- (void)settracktintcolor:(uicolor *)tracktintcolor

- (void)setprogresstintcolor:(uicolor *)progresstintcolor

- (void)setprogressfulltintcolor:(uicolor *)progressfulltintcolor

}- (void

)setlinewidth:(cgfloat)linewidth

}- (void

)settrackerwidth:(cgfloat)trackerwidth

}#pragma mark - setter (ccprogressviewstylecircle)

- (void)setfillcolor:(uicolor *)fillcolor

- (void

)setclockwise:(bool)clockwise

- (void

)setstartangle:(cgfloat)startangle

- (void

)setprogress:(cgfloat)progress

- (void

)setprogress:(cgfloat)progress animated:(bool)animated

else

@weakify(self);

basicanim.completionblock = ^(popanimation *anim, bool finished)

};[self.progresslayer pop_addanimation:basicanim forkey:kpopshapelayerstrokeend];

} else

}}@end

ios弧形進度條 iOS 圓形進度條

釋放雙眼,帶上耳機,聽聽看 今天產品要弄乙個圓形的進度條 有很多開源的進度條不用,非要弄這種效果,就不吐槽了,還是想想怎麼實現 廢話就不多說了 直接上 import inte ce roundprogressview uiview 進度條顏色 property strong,nonatomic ui...

ios弧形進度條 ios 圓形進度條

今天產品要弄乙個圓形的進度條 有很多開源的進度條不用,非要弄這種效果,就不吐槽了,還是想想怎麼實現 廢話就不多說了 直接上 import inte ce roundprogressview uiview 進度條顏色 property strong,nonatomic uicolor progress...

圓形進度條

public class circleprogress extends view public int getmheight public void setmheight int mheight public int getmwidth public void setmwidth int mwidt...