誰もがまだ404です。今日、私たちは愛するU、より正確にはUIKitフレームワークに飛び込んでいます。つまり、UIKitは、開発者がユーザーと対話するためのインターフェイスを簡単に作成できるようにするUIフレームワークです。しかし、UIKitには膨大な量の機能が含まれているにもかかわらず、そのサイズは数十キロバイトで計算されます。この理由は、最新のiOSのUIKitは、本質的に単一のインポートポイントを提供する包括的なヘッダーであるという事実です 。
そのまま入力
UIKitには、ユーザーがアプリケーションと通信するために使用するデバイスへのアクセスを提供するために必要なすべてのコンポーネントが含まれています。これらは、加速度計、ハードウェアボタン、外部キーボード、障害を持つ人々のための特別な入力デバイス、マウス、鉛筆(Apple Pencil)です。
上記の入力デバイスに加えて、UIKitは、低レベルのアプリケーションライフサイクルイベントやメモリ警告から始まり、高レベルのプッシュ通知で終わる、システムから多くの情報を受信して処理することを忘れないでください。
このような多数の着信イベントソースを効率的に処理するために、UIKitにはイベントループが必要です。これは、RunLoopと呼ばれてい ました。ここで、UIKitは、着信ソースとコードを順番に提供するメインスレッドの概念を導入します。メインスレッドはアプリケーションに固有のものであると一般に認められていますが、実際には、UIKitが導入して提供するのは抽象化です。
, RunLoop' — - , . , UIKit UI . , . , , . . , , RunLoop', UIKit' UI Tracking Mode. UI, .
, ?
Haptic. UI , , UIKit. , Apple Core Audio.
, . iOS, , 2D , - . : , , GPU. : .
, Layout
UIKit — . , view' , subview subview. . , , , .
, , autolayout 3rd-party . , iOS — , .
autolayout iOS . UIView , Core Animation, c anchorPoint .
.
— . - . Apple , LayerKit, Core Animation.
Core Animation — , . , , , - . , - , Core Animation , .
Core Animation , . UIView CALayer, . , view, . : , UIView UI, CALayer. view, . frame
, bounds
, center
, backgroundColor
CALayer.
UIView : UIView User Interaction, CALayer .
Core Animation iOS UIKit
UIView
, macOS AppKitNSView
. macOS iOS: — , iOS. Core Animation ApplegeometryFlipped
CALayer. macOS , UIKitgeometryFlipped = true
. , , , .
, Core Animation , . , CALayer - CoreGraphics . , CAShapeLayer
, CATextLayer
, CAGradientLayer
. , GPU.
, UIView
draw(in:)
. , GPU,draw(in:)
CoreGraphics, CPU. UI. , CoreGraphics ( , ), CPU.
-
CoreAnimation, : - CALayer ( ) , .
, CoreAnimation , , - . , CATransaction. CATransaction — , , . UIKit CATransaction RunLoop', . , «» . , CATransaction, .
CALayer , UIView - . frame
UIView , , . , UIView view . , , action(for:forKey:)
View nil' , UIView.animate(...)
, .
, actions
, - .
, addSublayer()
UIView UIView.animate(withDuration:5)
. : 5 , ( ) . .
⚠️ UIView . , view , .
-
, , . CAAnimation
, ( ), -, , «», «» . , CAAnimation
— , . , , « »:
[CABasicAnimation]
— ,fromPoint
toPoint
[CAKeyFrameAnimation]
— , ,values
keyTimes
[CASpringAnimation]
—
presentationLayer
. , . , , , . , «» «» . presentationLayer
, , . :
( )
(
fromValue
presentation )(
hitTest(_:with:)
(point(inside:with:)
) , ,point(inside:with:)
)
, isRemovedOnCompletion
. false
.
アニメーションは、アプリケーションのライフサイクルとレイヤー自体に依存することを覚えておく価値があります。アプリケーションがバックグラウンドに入るか、レイヤーがスーパービューから削除される と、 アニメーション CAAnimation
が削除されるため、アニメーションの途中でアプリケーションを最小化すると、アニメーションが開始される前の状態のオブジェクトが表示されます。
そして、これがおとぎ話の終わりです
少なくとも少しは、何か新しいものを見つけたり、棚にある既存の知識を分解したりしていただければ幸いです。すべての興味深いプロジェクトとクリーンなコード:D