久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<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="qwawimqqmiuu" 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 圓和動(dòng)畫大小/顏色

        drawRect circle and animate size/color(drawRect 圓和動(dòng)畫大小/顏色)
        <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="qwawimqqmiuu" 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 圓和動(dòng)畫大小/顏色的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                  問(wèn)題描述

                  限時(shí)送ChatGPT賬號(hào)..

                  我正在使用標(biāo)準(zhǔn) CGContextFillEllipseInRect() 代碼在 UIView-drawRect: 方法中畫一個(gè)圓.但是,我想稍微脈沖(變大和變小)并用動(dòng)畫改變顏色填充的強(qiáng)度.例如,如果圓圈充滿紅色,我想給圓圈打脈沖,并隨著脈沖動(dòng)作及時(shí)使紅色稍微變亮和變暗.我對(duì) Core Animation 沒(méi)有太多經(jīng)驗(yàn),我對(duì)如何做到這一點(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è)就簡(jiǎn)單多了.相反,將您的視圖設(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)都會(huì)將 layoutSubviews 發(fā)送到您的視圖.我們重寫 layoutSubviews 來(lái)設(shè)置形狀并為其設(shè)置動(dòng)畫:

                  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è)動(dòng)畫——一個(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è)置動(dòng)畫的方式:

                  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è)置動(dòng)畫:

                  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è)基本動(dòng)畫并將其設(shè)置為通過(guò)自動(dòng)反轉(zhuǎn)和一秒的持續(xù)時(shí)間無(wú)限期重復(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 圓和動(dòng)畫大小/顏色的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

                  How to animate a UIImageview to display fullscreen by tapping on it?(如何通過(guò)點(diǎn)擊動(dòng)畫 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="qwawimqqmiuu" 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'>

                            主站蜘蛛池模板: 亚洲精品二区 | 国产成人三级 | 亚洲欧美国产高清va在线播放 | 亚洲精品一区二区三区在线 | 久国产| 天天爽天天干 | 精品欧美一区二区精品久久 | 久久亚洲国产精品 | 欧美日韩一区二区在线 | a视频 | 在线免费黄色网址 | 日韩精品久久久久久久 | 亚洲爱爱网| 黄色小视频免费观看 | 久久天天操 | 欧美精品在线免费观看 | av网站免费看 | 国产精品久久久久久亚洲影视 | 成人精品国产 | 深夜福利在线播放 | 日本欧美在线观看 | www.九色 | 黄色网视频 | 亚洲成年人在线观看 | 精品久久久久久久久久久久久 | 久久中文字幕视频 | 日韩国产精品视频 | 天堂av网站 | 日韩一区二区中文字幕 | 成人毛片在线播放 | 亚洲视频网 | 中文字幕av久久爽av | 国产一二| 日韩免费一区二区三区 | 免费日韩av | 少妇一级淫片免费放 | 能看的av网站| 久草青青草 | 不卡的av在线 | 一区二区免费 | 国产一区二区三区四区 |