日本不卡不码高清免费观看,久久国产精品久久w女人spa,黄色aa久久,三上悠亚国产精品一区二区三区

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

iOS實(shí)現(xiàn)輪盤動(dòng)態(tài)效果

瀏覽:21日期:2022-09-17 09:44:45

本文實(shí)例為大家分享了iOS實(shí)現(xiàn)輪盤動(dòng)態(tài)效果的具體代碼,供大家參考,具體內(nèi)容如下

一個(gè)常用的繪圖,主要用來(lái)打分之類的動(dòng)畫,效果如下。

iOS實(shí)現(xiàn)輪盤動(dòng)態(tài)效果

主要是iOS的繪圖和動(dòng)畫,本來(lái)想用系統(tǒng)自帶動(dòng)畫實(shí)現(xiàn)呢,發(fā)現(xiàn)實(shí)現(xiàn)不了,用了其他辦法延時(shí)并重繪視圖沒有成功,用了gcd延時(shí),nsthread休眠,performselector delay 都不行。最后用了一個(gè)定時(shí)器實(shí)現(xiàn)類似效果,總感覺不太明智,以后應(yīng)該考慮下對(duì)CALayer和

隱式動(dòng)畫的角度考慮下

#import <UIKit/UIKit.h> /** * 自定義變量里面以s結(jié)尾的表示具體的數(shù)值,否則表示的是表示顯示具體內(nèi)容的標(biāo)簽,以lbe的表示對(duì)內(nèi)容的說(shuō)明 比如comments 表示的具體評(píng)價(jià)內(nèi)容,comment 表示評(píng)價(jià)的具體內(nèi)容,lbecomment 是一個(gè)顯示 '評(píng)價(jià):'的標(biāo)簽 */ @interface ScorePlateView : UIView /*速度滿意度*/@property (nonatomic,assign) CGFloat speedValues; /*態(tài)度滿意度*/@property (nonatomic,assign) CGFloat altitudeValues; /*把半圓分割的份數(shù)*/@property (nonatomic,assign) int precision;/** * 整體評(píng)價(jià) */@property (nonatomic,strong) NSString * comments;/** * 滿分是多少分 */@property (nonatomic,assign) CGFloat fullValues;/** * 綜合評(píng)分 */@property (nonatomic,assign) CGFloat compreValues;/** * 開始角度 */ @property (nonatomic,assign) CGFloat startAngle;/** * 終止角度 */@property (nonatomic,assign) CGFloat endAngle; //-(void)startAnimation;@end

#import 'ScorePlateView.h' @interface ScorePlateView(){ CGFloat d_speed;//執(zhí)行動(dòng)畫時(shí)候每個(gè)的增量 CGFloat d_altitude; CGFloat d_comp;} @property (nonatomic,strong) UILabel*lbeCompreValue;//綜合分?jǐn)?shù)的標(biāo)簽 @property (nonatomic,strong) UILabel *compreValue;//綜合分?jǐn)?shù)的具體數(shù)值 @property (nonatomic,strong) UILabel * comment;//評(píng)價(jià) @property (nonatomic,assign) CGFloat cur_speedV;//當(dāng)前的值 @property (nonatomic,assign) CGFloat cur_altitudeV;//當(dāng)前的態(tài)度; @property (nonatomic,assign) CGFloat cur_compV;//當(dāng)前的綜合分?jǐn)?shù)@property (nonatomic,assign) NSTimer * timer; @end @implementation ScorePlateView - (instancetype)initWithFrame:(CGRect)frame{ if (self = [super initWithFrame:frame]) {self.precision= 50;//這里設(shè)置默認(rèn)值; self.fullValues =5; self.altitudeValues=3.0; self.speedValues=4.0; self.backgroundColor = [UIColor clearColor]; self.startAngle=0.1*M_PI; self.endAngle = 0.9*M_PI; self.comments =@'真是太不可思議了'; self.backgroundColor = [UIColor greenColor]; _cur_compV=0; _cur_speedV=0; _cur_altitudeV=0; } return self;}- (void)drawRect:(CGRect)rect { //1. 畫圓 CGFloat circleMargin = 0; //上下兩個(gè)半圓的間距 CGFloat topBottomMargin =20;//這個(gè)間距用來(lái)顯示服務(wù)態(tài)度和服務(wù)速度那樣標(biāo)簽內(nèi)容 CGFloat radius = (self.frame.size.height-circleMargin-2*topBottomMargin)/2;//半徑 //上邊圓的圓心 CGPoint centerTop = CGPointMake(self.frame.size.width/2,self.frame.size.height/2-circleMargin/2); [self drawHalfCircle:centerTop andWithRadius:radius isTop:YES]; //下面圓的圓心 CGPoint centerBottom = CGPointMake(self.frame.size.width/2, self.frame.size.height/2+circleMargin/2); [self drawHalfCircle:centerBottom andWithRadius:radius isTop:NO]; //2. 創(chuàng)建需要的標(biāo)簽,并在合適的位置繪制內(nèi)容 UILabel * lbeAltitude = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, self.frame.size.width, topBottomMargin)]; lbeAltitude.text = @'服務(wù)速度'; lbeAltitude.textColor = [UIColor whiteColor]; lbeAltitude.textAlignment = NSTextAlignmentCenter; lbeAltitude.font = [UIFont systemFontOfSize:12]; [lbeAltitude drawTextInRect:lbeAltitude.frame]; //服務(wù)態(tài)度評(píng)分 UILabel * lbeSpeed = [[UILabel alloc]initWithFrame:CGRectMake(0, self.frame.size.height-topBottomMargin, self.frame.size.width, topBottomMargin)]; lbeSpeed.text = @'服務(wù)態(tài)度'; lbeSpeed.textColor = [UIColor whiteColor]; lbeSpeed.textAlignment = NSTextAlignmentCenter; lbeSpeed.font = [UIFont systemFontOfSize:12]; [lbeSpeed drawTextInRect:lbeSpeed.frame]; //繪制綜合評(píng)分 NSString *attitudeScore = [NSString stringWithFormat:@'%.2f/%.2f',_cur_altitudeV,self.fullValues]; NSMutableAttributedString* attributeString = [[NSMutableAttributedString alloc]initWithString:attitudeScore]; [attributeString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:26] range:NSMakeRange(0, 4)]; [attributeString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:16] range:NSMakeRange(4, 3)]; self.compreValue = [[UILabel alloc]initWithFrame:CGRectMake(0, radius-topBottomMargin,self.frame.size.width, 2*topBottomMargin)]; self.compreValue.attributedText = attributeString; self.compreValue.textAlignment = NSTextAlignmentCenter; self.compreValue.textColor = [UIColor whiteColor]; self.compreValue.frame = CGRectMake(0, centerTop.y-topBottomMargin+circleMargin/2, self.frame.size.width, topBottomMargin*2); [self.compreValue drawTextInRect:self.compreValue.frame]; self.lbeCompreValue = [[UILabel alloc]initWithFrame:CGRectMake(0, centerTop.y-radius*0.5, self.frame.size.width, topBottomMargin*2)]; self.lbeCompreValue.text =@'綜合評(píng)分'; self.lbeCompreValue.textAlignment = NSTextAlignmentCenter; self.lbeCompreValue.textColor = [UIColor whiteColor]; self.lbeCompreValue.font = [UIFont systemFontOfSize:14]; [self.lbeCompreValue drawTextInRect:self.lbeCompreValue.frame]; //評(píng)價(jià)內(nèi)容 self.comment = [[UILabel alloc]initWithFrame:CGRectMake(topBottomMargin+circleMargin+radius/2, CGRectGetMaxY(self.compreValue.frame), radius, topBottomMargin*2)]; self.comment.text =self.comments; self.comment.numberOfLines=0; self.comment.textAlignment = NSTextAlignmentCenter; self.comment.textColor = [UIColor whiteColor]; self.comment.font = [UIFont systemFontOfSize:14]; [self.comment drawTextInRect:self.comment.frame]; }/** * 畫半圓 繪制刻度的時(shí)候可以先繪制從圓心的線,最后用一個(gè)內(nèi)圓裁剪的方式,但是如果要求背景隨時(shí)變化就局限了,特別是父視圖背景是漸變的,要么重新定義該類,要么把這個(gè)類視圖定義為透明,從而透過(guò)父視圖背景顏色 透明的背景無(wú)法掩蓋從圓心出發(fā)的線, * * @param center 圓心坐標(biāo) * @param radius 半徑 * @param top 是不是畫上面的圓 */-(void)drawHalfCircle:(CGPoint) center andWithRadius:(CGFloat)radius isTop:(BOOL) top{ //畫上面圓的邊框 CGContextRef ctx = UIGraphicsGetCurrentContext(); CGContextSetStrokeColorWithColor(ctx, [UIColor whiteColor].CGColor); if (top) { CGContextAddArc(ctx, center.x, center.y, radius, -self.startAngle, -self.endAngle, 1); } else { CGContextAddArc(ctx, center.x, center.y, radius,self.startAngle,self.endAngle, 0); } //設(shè)置線的寬度 CGContextSetLineWidth(ctx, 1); CGContextSetStrokeColorWithColor(ctx, [UIColor whiteColor].CGColor); CGContextStrokePath(ctx); //繪制上下圓的分割線 CGContextSetLineWidth(ctx, 2);//設(shè)置線寬 CGFloat borderValue; if (top) { borderValue=_cur_altitudeV/self.fullValues;//設(shè)置邊界值 } else { borderValue =_cur_speedV/self.fullValues; } //實(shí)現(xiàn)動(dòng)畫效果,只能先畫刻度,再畫具體值 for (int i=1; i<self.precision; i++)//畫刻度 {CGContextSetRGBStrokeColor(ctx, 1.0, 1.0, 1.0, 0.5);//設(shè)置白色 透明 CGFloat endX,endY,startX,startY;//刻度的長(zhǎng)度是這里 7 -2 =5; if (top) { startX = center.x -(radius-10)*cos((double)i/self.precision*(self.endAngle-self.startAngle)+self.startAngle); startY = center.y - (radius-10)*sin((double)i/self.precision*(self.endAngle-self.startAngle)+self.startAngle); endX = center.x - (radius-2)*cos((double)i/self.precision*(self.endAngle-self.startAngle)+self.startAngle);//圓上的點(diǎn)的x坐標(biāo) endY = center.y - (radius-2)*sin((double)i/self.precision*(self.endAngle-self.startAngle)+self.startAngle);//圓上的點(diǎn)的y坐標(biāo) } else { startX = center.x +(radius-10)*cos((double)i/self.precision*(self.endAngle-self.startAngle)+self.startAngle); startY = center.y + (radius-10)*sin((double)i/self.precision*(self.endAngle-self.startAngle)+self.startAngle); endX = center.x + (radius-2)*cos((double)i/self.precision*(self.endAngle-self.startAngle)+self.startAngle);//圓上的點(diǎn)的x坐標(biāo) endY = center.y + (radius-2)*sin((double)i/self.precision*(self.endAngle-self.startAngle)+self.startAngle);//圓上的點(diǎn)的y坐標(biāo) } CGContextMoveToPoint(ctx, startX, startY); CGContextAddLineToPoint(ctx, endX, endY); CGContextStrokePath(ctx); } for (int i=1; i<self.precision; i++) {CGFloat curAngle =(double)i/self.precision*(self.endAngle-self.startAngle)+self.startAngle; if ((double)i/(double)self.precision<borderValue) { CGContextSetRGBStrokeColor(ctx, 1.0, 1.0, 1.0, 1);//設(shè)置白色 不透明 CGFloat endX,endY,startX,startY;//刻度的長(zhǎng)度是這里 7 -2 =5; if (top) {startX = center.x -(radius-10)*cos(curAngle);startY = center.y - (radius-10)*sin(curAngle);endX = center.x - (radius-2)*cos(curAngle);//圓上的點(diǎn)的x坐標(biāo)endY = center.y - (radius-2)*sin(curAngle);//圓上的點(diǎn)的y坐標(biāo) } else {startX = center.x +(radius-10)*cos(curAngle);startY = center.y + (radius-10)*sin(curAngle);endX = center.x + (radius-2)*cos(curAngle);//圓上的點(diǎn)的x坐標(biāo)endY = center.y + (radius-2)*sin(curAngle);//圓上的點(diǎn)的y坐標(biāo) } CGContextMoveToPoint(ctx, startX, startY); CGContextAddLineToPoint(ctx, endX, endY); CGContextStrokePath(ctx); } }}- (void)didMoveToSuperview{ self.timer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(update) userInfo:nil repeats:YES]; d_comp = self.compreValues/20; d_speed= self.speedValues/20; d_altitude=self.speedValues/20;}-(void)update{ _cur_altitudeV+=d_altitude; _cur_speedV+=d_speed; _cur_compV+=d_comp; if (_cur_altitudeV>self.altitudeValues) { _cur_altitudeV =self.altitudeValues; } if (_cur_speedV > self.speedValues) { _cur_speedV=self.speedValues; } if (_cur_compV>self.compreValues) { _cur_compV=self.compreValues; } if ( _cur_compV==self.compreValues&&_cur_speedV==self.speedValues&&_cur_altitudeV ==self.altitudeValues) {[self.timer invalidate]; self.timer = nil; } //self.backgroundColor = [UIColor colorWithRed:arc4random()%255/255.0 green:arc4random()%255/255.0 blue:arc4random()%255/255.0 alpha:1]; [self setNeedsDisplay]; } @end

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。

標(biāo)簽: IOS
相關(guān)文章:
日本不卡不码高清免费观看,久久国产精品久久w女人spa,黄色aa久久,三上悠亚国产精品一区二区三区
国产精品久久久久9999高清| 欧美1区2区3区| 亚洲国产日韩欧美在线| 久久久男人天堂| 国产精品二区不卡| 国产一区二区三区四区| 视频在线不卡免费观看| 日韩不卡一区| 国产综合色区在线观看| 91精品xxx在线观看| 久久精品国产亚洲aⅴ| 精品久久久亚洲| 国产精品99久久精品| av资源中文在线天堂| 久久精品中文| 99香蕉国产精品偷在线观看| 六月天综合网| 亚洲精品一级| 国产精品中文| 国产一区二区三区久久久久久久久| 精品国产网站| 欧美+亚洲+精品+三区| 国产视频一区三区| 亚洲日韩视频| 国产精品一国产精品k频道56| 国产极品嫩模在线观看91精品| 精品国产aⅴ| 精品国模一区二区三区| 国产精品毛片| 日韩和欧美的一区| 美女久久99| 99久久九九| 日韩中文字幕1| 日本午夜精品久久久久| 国产一区二区三区四区| 香蕉精品久久| 亚洲毛片在线免费| 精品国产aⅴ| 午夜久久tv| 日韩精品第二页| 精品网站aaa| 美女精品一区| 精品免费视频| 中文精品视频| 国产极品一区| 亚洲精品123区| 国产精品mv在线观看| 欧美片第1页| 亚洲午夜免费| 91日韩在线| 在线看片一区| 国产精品福利在线观看播放| 亚洲免费网址| 国产在线不卡一区二区三区| 一区二区亚洲精品| 国产欧美在线| 亚洲午夜精品久久久久久app| 日本中文字幕视频一区| 亚洲天堂av影院| 日韩在线视频一区二区三区| 日韩av在线播放网址| 亚洲精品日本| 久久精品青草| 国产精品久久久久久久久久白浆 | 国产精品亚洲欧美日韩一区在线| 国产精选在线| 亚洲另类视频| 秋霞影视一区二区三区| 欧美一级二级视频| 香蕉国产精品| 国产欧美日韩在线观看视频| 香蕉国产精品| 日韩av片子| 日韩va亚洲va欧美va久久| 欧美gv在线| 久久精品97| 亚洲激情偷拍| 正在播放日韩精品| 国产精品任我爽爆在线播放| 亚洲免费高清| 亚洲精品**中文毛片| 国产精品亚洲成在人线| 视频一区欧美日韩| 成人羞羞在线观看网站| 国产精品亚洲二区| 日本不卡视频在线观看| 日韩亚洲在线| 99国产精品免费视频观看| 牛牛精品成人免费视频| 日本麻豆一区二区三区视频| 五月天综合网站| 日韩欧美综合| 精品久久福利| 国产精品jk白丝蜜臀av小说| 色8久久久久| 中文精品电影| 午夜在线精品| 免费av一区| 日韩精品网站| 亚洲成人av观看| 国产一区二区三区天码| 国产精品theporn| 国产情侣久久| 91精品一区| 日韩午夜视频在线| 噜噜噜躁狠狠躁狠狠精品视频| 久久精品国产亚洲夜色av网站| 首页国产精品| 国产粉嫩在线观看| 国产suv精品一区二区四区视频 | 日韩电影二区| 日产午夜精品一线二线三线| 麻豆精品视频在线观看| 国产精选久久| 国产精品久久乐| 国产欧美一区二区三区国产幕精品| 一区二区国产在线观看| 爽好久久久欧美精品| 亚洲国产综合在线看不卡| 亚洲精品国产嫩草在线观看 | 激情久久五月| 欧美福利专区| 亚洲精品网址| 国产精品丝袜xxxxxxx| 亚洲欧美日韩国产一区二区| 日韩在线一区二区| 日韩一区网站| 欧美午夜三级| 国产精品99久久久久久董美香| 久久丁香四色| 久久这里只有| 国产一区二区三区四区五区| 成人在线黄色| 成人日韩在线观看| 国产专区一区| 视频一区视频二区中文| 日本国产欧美| 久久三级中文| 亚洲精品88| 影音国产精品| 亚洲精品日本| 国产日韩欧美三级| 美腿丝袜亚洲三区| 日本激情一区| 日韩av首页| 亚洲视频www| 亚洲一二av| 欧美三区不卡| 欧美激情aⅴ一区二区三区| 美女福利一区二区三区| 免费不卡中文字幕在线| 丝袜亚洲另类欧美| 欧美日韩调教| 中文一区一区三区高中清不卡免费| 久久蜜桃资源一区二区老牛| 9久re热视频在线精品| 日本中文字幕一区二区视频| 国产精品免费不| 麻豆成全视频免费观看在线看| 激情久久婷婷| 日韩av中文字幕一区二区三区| 国产欧美亚洲一区| 久久uomeier| 亚洲一区日韩在线| 久久国产视频网| 毛片在线网站| 日韩影院精彩在线| 国产精品亚洲综合久久| 日韩一区电影| 亚洲欧美在线专区| 欧美黄色精品| 午夜精品一区二区三区国产| 91大神在线观看线路一区| 精品女同一区二区三区在线观看| 亚洲不卡av不卡一区二区| 亚洲精品护士| 精品国产不卡| 黄色亚洲精品| 国产乱码精品| 欧美日韩激情| 国产精品久久久久久妇女 | 日韩精选在线| 在线观看精品| 日韩精品欧美大片| 麻豆视频在线看| 亚洲精品成人一区| 黑人精品一区| 日本免费一区二区视频| 亚洲国产福利| 免费观看在线色综合| 高清一区二区三区av| 亚洲综合图色| 高潮久久久久久久久久久久久久| 丝袜诱惑制服诱惑色一区在线观看 | 欧美日韩中文字幕一区二区三区| 91成人福利| 国产韩日影视精品| 国产精品v亚洲精品v日韩精品| 中文国产一区| 高潮一区二区|