久久久久久久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 圓和動畫大小/顏色

        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="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 圓和動畫大小/顏色的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

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

                  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:中畫圓,這個就簡單多了.相反,將您的視圖設置為使用 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];
                  }
                  

                  每當視圖大小發生變化時(包括首次出現時),系統都會將 layoutSubviews 發送到您的視圖.我們重寫 layoutSubviews 來設置形狀并為其設置動畫:

                  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];
                  }
                  

                  以下是我們如何設置圖層的路徑(決定其形狀)和形狀的填充顏色:

                  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;
                  }
                  

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

                  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];
                  }
                  

                  以下是我們為圖層路徑設置動畫的方式:

                  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];
                  }
                  

                  下面是我們如何為圖層的填充顏色設置動畫:

                  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];
                  }
                  

                  這兩個 attach*Animation 方法都使用了一個輔助方法,該方法創建一個基本動畫并將其設置為通過自動反轉和一秒的持續時間無限期重復:

                  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;
                  }
                  

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

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

                  相關文檔推薦

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

                            主站蜘蛛池模板: 亚洲精品自在在线观看 | 亚洲午夜精品一区二区三区 | 黄色片网站在线观看 | www.日本在线播放 | 中文字幕视频在线免费 | 免费久久精品视频 | 国产一区二区久久 | 羞羞在线观看视频 | 二区视频 | 99reav| 最新伦理片 | 91 久久 | 在线一区观看 | 精品国产鲁一鲁一区二区张丽 | 免费人成在线观看网站 | 国产精品性做久久久久久 | 亚洲欧美一区二区三区在线 | 大久| 91免费小视频 | 亚洲综合首页 | www日本在线播放 | 国产一区二区三区四区在线观看 | 99久久婷婷国产综合精品电影 | 久久网一区二区 | 国产精品伦理一区 | 欧美午夜精品理论片a级按摩 | 亚洲精品中文字幕中文字幕 | 亚洲视频一区在线观看 | 成人三级av| 欧美日韩国产精品激情在线播放 | 亚洲成人一二三 | 国产一二区免费视频 | 精品日韩 | 97人人干| 国产一区二区三区在线观看免费 | 亚洲欧洲精品一区 | 午夜国产 | 五月天婷婷综合 | 欧美日韩精品国产 | 精品国产一区二区三区成人影院 | 日韩一区二区在线播放 |