pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

<tfoot id='t2yxY'></tfoot>

    • <bdo id='t2yxY'></bdo><ul id='t2yxY'></ul>

    <i id='t2yxY'><tr id='t2yxY'><dt id='t2yxY'><q id='t2yxY'><span id='t2yxY'><b id='t2yxY'><form id='t2yxY'><ins id='t2yxY'></ins><ul id='t2yxY'></ul><sub id='t2yxY'></sub></form><legend id='t2yxY'></legend><bdo id='t2yxY'><pre id='t2yxY'><center id='t2yxY'></center></pre></bdo></b><th id='t2yxY'></th></span></q></dt></tr></i><div class="8frfswx" id='t2yxY'><tfoot id='t2yxY'></tfoot><dl id='t2yxY'><fieldset id='t2yxY'></fieldset></dl></div>

        <small id='t2yxY'></small><noframes id='t2yxY'>

      1. <legend id='t2yxY'><style id='t2yxY'><dir id='t2yxY'><q id='t2yxY'></q></dir></style></legend>

        drawRect 圓和動畫大小/顏色

        drawRect circle and animate size/color(drawRect 圓和動畫大小/顏色)
        <i id='PXPsx'><tr id='PXPsx'><dt id='PXPsx'><q id='PXPsx'><span id='PXPsx'><b id='PXPsx'><form id='PXPsx'><ins id='PXPsx'></ins><ul id='PXPsx'></ul><sub id='PXPsx'></sub></form><legend id='PXPsx'></legend><bdo id='PXPsx'><pre id='PXPsx'><center id='PXPsx'></center></pre></bdo></b><th id='PXPsx'></th></span></q></dt></tr></i><div class="3gq372m" id='PXPsx'><tfoot id='PXPsx'></tfoot><dl id='PXPsx'><fieldset id='PXPsx'></fieldset></dl></div>
        <tfoot id='PXPsx'></tfoot>
            <tbody id='PXPsx'></tbody>

            <small id='PXPsx'></small><noframes id='PXPsx'>

            <legend id='PXPsx'><style id='PXPsx'><dir id='PXPsx'><q id='PXPsx'></q></dir></style></legend>
              <bdo id='PXPsx'></bdo><ul id='PXPsx'></ul>

                  本文介紹了drawRect 圓和動畫大小/顏色的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  限時(shí)送ChatGPT賬號..

                  我正在使用標(biāo)準(zhǔn) CGContextFillEllipseInRect() 代碼在 UIView-drawRect: 方法中畫一個(gè)圓.但是,我想稍微脈沖(變大和變小)并用動畫改變顏色填充的強(qiáng)度.例如,如果圓圈充滿紅色,我想給圓圈打脈沖,并隨著脈沖動作及時(shí)使紅色稍微變亮和變暗.我對 Core Animation 沒有太多經(jīng)驗(yàn),我對如何做到這一點(diǎn)有點(diǎn)迷茫,所以任何幫助都將不勝感激.

                  I am drawing a circle in the -drawRect: method of my UIView using the standard CGContextFillEllipseInRect() code. However, I would like to slightly pulse (make larger and smaller) and change the intensity of the color fill with an animation. For example, if the circle is filled with red I would like to pulse the circle and make the red slightly lighter and darker in-time with the pulsing action. Not having much experience with Core Animation I am a bit lost about how to do this, so any help would be greatly appreciated.

                  推薦答案

                  如果你不在drawRect:中畫圓,這個(gè)就簡單多了.相反,將您的視圖設(shè)置為使用 CAShapeLayer,如下所示:

                  This is much simpler if you don't draw the circle in drawRect:. Instead, set up your view to use a CAShapeLayer, like this:

                  @implementation PulseView
                  
                  + (Class)layerClass {
                      return [CAShapeLayer class];
                  }
                  

                  每當(dāng)視圖大小發(fā)生變化時(shí)(包括首次出現(xiàn)時(shí)),系統(tǒng)都會將 layoutSubviews 發(fā)送到您的視圖.我們重寫 layoutSubviews 來設(shè)置形狀并為其設(shè)置動畫:

                  The system sends layoutSubviews to your view whenever it changes size (including when it first appears). We override layoutSubviews to set up the shape and animate it:

                  - (void)layoutSubviews {
                      [self setLayerProperties];
                      [self attachAnimations];
                  }
                  

                  以下是我們?nèi)绾卧O(shè)置圖層的路徑(決定其形狀)和形狀的填充顏色:

                  Here's how we set the layer's path (which determines its shape) and the fill color for the shape:

                  - (void)setLayerProperties {
                      CAShapeLayer *layer = (CAShapeLayer *)self.layer;
                      layer.path = [UIBezierPath bezierPathWithOvalInRect:self.bounds].CGPath;
                      layer.fillColor = [UIColor colorWithHue:0 saturation:1 brightness:.8 alpha:1].CGColor;
                  }
                  

                  我們需要給圖層附加兩個(gè)動畫——一個(gè)用于路徑,一個(gè)用于填充顏色:

                  We need to attach two animations to the layer - one for the path and one for the fill color:

                  - (void)attachAnimations {
                      [self attachPathAnimation];
                      [self attachColorAnimation];
                  }
                  

                  以下是我們?yōu)閳D層路徑設(shè)置動畫的方式:

                  Here's how we animate the layer's path:

                  - (void)attachPathAnimation {
                      CABasicAnimation *animation = [self animationWithKeyPath:@"path"];
                      animation.toValue = (__bridge id)[UIBezierPath bezierPathWithOvalInRect:CGRectInset(self.bounds, 4, 4)].CGPath;
                      animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
                      [self.layer addAnimation:animation forKey:animation.keyPath];
                  }
                  

                  下面是我們?nèi)绾螢閳D層的填充顏色設(shè)置動畫:

                  Here's how we animate the layer's fill color:

                  - (void)attachColorAnimation {
                      CABasicAnimation *animation = [self animationWithKeyPath:@"fillColor"];
                      animation.fromValue = (__bridge id)[UIColor colorWithHue:0 saturation:.9 brightness:.9 alpha:1].CGColor;
                      [self.layer addAnimation:animation forKey:animation.keyPath];
                  }
                  

                  這兩個(gè) attach*Animation 方法都使用了一個(gè)輔助方法,該方法創(chuàng)建一個(gè)基本動畫并將其設(shè)置為通過自動反轉(zhuǎn)和一秒的持續(xù)時(shí)間無限期重復(fù):

                  Both of the attach*Animation methods use a helper method that creates a basic animation and sets it up to repeat indefinitely with autoreverse and a one second duration:

                  - (CABasicAnimation *)animationWithKeyPath:(NSString *)keyPath {
                      CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:keyPath];
                      animation.autoreverses = YES;
                      animation.repeatCount = HUGE_VALF;
                      animation.duration = 1;
                      return animation;
                  }
                  

                  這篇關(guān)于drawRect 圓和動畫大小/顏色的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  How to animate a UIImageview to display fullscreen by tapping on it?(如何通過點(diǎn)擊動畫 UIImageview 以顯示全屏?)
                  To stop segue and show alert(停止 segue 并顯示警報(bào))
                  iOS 5 storyboard, programmatically determine path(iOS 5 故事板,以編程方式確定路徑)
                  Icon already includes gloss effects(圖標(biāo)已經(jīng)包含光澤效果)
                  How does UIEdgeInsetsMake work?(UIEdgeInsetsMake 是如何工作的?)
                  UIProgressView and Custom Track and Progress Images (iOS 5 properties)(UIProgressView 和自定義跟蹤和進(jìn)度圖像(iOS 5 屬性))

                      <legend id='Vkc2q'><style id='Vkc2q'><dir id='Vkc2q'><q id='Vkc2q'></q></dir></style></legend>
                        • <tfoot id='Vkc2q'></tfoot>

                            <tbody id='Vkc2q'></tbody>
                          <i id='Vkc2q'><tr id='Vkc2q'><dt id='Vkc2q'><q id='Vkc2q'><span id='Vkc2q'><b id='Vkc2q'><form id='Vkc2q'><ins id='Vkc2q'></ins><ul id='Vkc2q'></ul><sub id='Vkc2q'></sub></form><legend id='Vkc2q'></legend><bdo id='Vkc2q'><pre id='Vkc2q'><center id='Vkc2q'></center></pre></bdo></b><th id='Vkc2q'></th></span></q></dt></tr></i><div class="d88ez88" id='Vkc2q'><tfoot id='Vkc2q'></tfoot><dl id='Vkc2q'><fieldset id='Vkc2q'></fieldset></dl></div>
                            <bdo id='Vkc2q'></bdo><ul id='Vkc2q'></ul>
                          • <small id='Vkc2q'></small><noframes id='Vkc2q'>

                            主站蜘蛛池模板: 澳门精准正版免费大全,2025新澳门全年免费,新澳天天开奖免费资料大全最新,新澳2025今晚开奖资料,新澳马今天最快最新图库-首页-东莞市傲马网络科技有限公司 | 长江船运_国内海运_内贸船运_大件海运|运输_船舶运输价格_钢材船运_内河运输_风电甲板船_游艇运输_航运货代电话_上海交航船运 | 欧盟ce检测认证_reach检测报告_第三方检测中心-深圳市威腾检验技术有限公司 | 广州食堂承包_广州团餐配送_广州堂食餐饮服务公司 - 旺记餐饮 | nalgene洗瓶,nalgene量筒,nalgene窄口瓶,nalgene放水口大瓶,浙江省nalgene代理-杭州雷琪实验器材有限公司 | 东莞喷砂机-喷砂机-喷砂机配件-喷砂器材-喷砂加工-东莞市协帆喷砂机械设备有限公司 | 膜结构_ETFE膜结构_膜结构厂家_膜结构设计-深圳市烨兴智能空间技术有限公司 | 悬浮拼装地板_篮球场木地板翻新_运动木地板价格-上海越禾运动地板厂家 | 膜片万向弹性联轴器-冲压铸造模具「沧州昌运模具」 | 宝宝药浴-产后药浴-药浴加盟-艾裕-专注母婴调养泡浴 | 砂磨机_立式纳米砂磨机_实验室砂磨机-广州儒佳化工设备厂家 | 废旧物资回收公司_广州废旧设备回收_报废设备物资回收-益美工厂设备回收公司 | 天津市能谱科技有限公司-专业的红外光谱仪_红外测油仪_紫外测油仪_红外制样附件_傅里叶红外光谱技术生产服务厂商 | 精密五金冲压件_深圳五金冲压厂_钣金加工厂_五金模具加工-诚瑞丰科技股份有限公司 | 123悬赏网_发布悬赏任务_广告任务平台| DDoS安全防护官网-领先的DDoS安全防护服务商 | 济南网站建设|济南建网站|济南网站建设公司【济南腾飞网络】【荐】 | 砍排机-锯骨机-冻肉切丁机-熟肉切片机-预制菜生产线一站式服务厂商 - 广州市祥九瑞盈机械设备有限公司 | 流水线电子称-钰恒-上下限报警电子秤-上海宿衡实业有限公司 | 盘古网络技术有限公司 | 对辊式破碎机-对辊制砂机-双辊-双齿辊破碎机-巩义市裕顺机械制造有限公司 | 移动厕所租赁|移动卫生间|上海移动厕所租赁-家瑞租赁 | 上海小程序开发-上海小程序制作公司-上海网站建设-公众号开发运营-软件外包公司-咏熠科技 | 减速机电机一体机_带电机减速器一套_德国BOSERL电动机与减速箱生产厂家 | 干培两用箱-细菌恒温培养箱-菲斯福仪器 | 河北码上网络科技|邯郸小程序开发|邯郸微信开发|邯郸网站建设 | 全温恒温摇床-水浴气浴恒温摇床-光照恒温培养摇床-常州金坛精达仪器制造有限公司 | 长江船运_国内海运_内贸船运_大件海运|运输_船舶运输价格_钢材船运_内河运输_风电甲板船_游艇运输_航运货代电话_上海交航船运 | 视觉检测设备_自动化检测设备_CCD视觉检测机_外观缺陷检测-瑞智光电 | 成都思迪机电技术研究所-四川成都思迪编码器 | 耐火浇注料-喷涂料-浇注料生产厂家_郑州市元领耐火材料有限公司 耐力板-PC阳光板-PC板-PC耐力板 - 嘉兴赢创实业有限公司 | 考试试题_试卷及答案_诗词单词成语 - 优易学 | 加中寰球移民官网-美国移民公司,移民机构,移民中介,移民咨询,投资移民 | DNA亲子鉴定_DNA基因检测中心官方预约平台-严选好基因网 | 2-羟基泽兰内酯-乙酰蒲公英萜醇-甘草查尔酮A-上海纯优生物科技有限公司 | 真空泵维修保养,普发,阿尔卡特,荏原,卡西亚玛,莱宝,爱德华干式螺杆真空泵维修-东莞比其尔真空机电设备有限公司 | 知名电动蝶阀,电动球阀,气动蝶阀,气动球阀生产厂家|价格透明-【固菲阀门官网】 | 全自动固相萃取仪_高通量真空平行浓缩仪-勤业永为 | 蜜蜂职场文库_职场求职面试实用的范文资料大全 | 巨野电机维修-水泵维修-巨野县飞宇机电维修有限公司 | 散热器-电子散热器-型材散热器-电源散热片-镇江新区宏图电子散热片厂家 |