{"id":331424,"date":"2022-04-03T03:00:18","date_gmt":"2022-04-03T03:00:18","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=331424"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=331424","title":{"rendered":"<span>[iOS] \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 \u043b\u043e\u0430\u0434\u0435\u0440 (\u0441\u043f\u0438\u043d\u043d\u0435\u0440 \u0438\u043b\u0438 UIActivityIndicator) \u0432 UIKit<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<h2>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0412\u0441\u0435 \u043c\u044b \u0437\u043d\u0430\u0435\u043c \u043a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0438\u043d\u0434\u0438\u043a\u0430\u0442\u043e\u0440 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 (\u0434\u0430\u043b\u0435\u0435 &#8212; \u0441\u043f\u0438\u043d\u043d\u0435\u0440 \u0438\u043b\u0438 \u043b\u043e\u0430\u0434\u0435\u0440) \u043d\u0430 \u043d\u0430\u0448\u0438\u0445 iOS \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u043a\u0435\u0439\u0441\u0430\u0445, \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0432\u044b\u043d\u0443\u0436\u0434\u0435\u043d \u0436\u0434\u0430\u0442\u044c \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u0435 \u043a\u0430\u043a\u043e\u0433\u043e-\u043b\u0438\u0431\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430. \u041d\u043e \u043c\u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u044b\u043b\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 \u043b\u043e\u0430\u0434\u0435\u0440, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u0435\u0433\u043e \u0432 \u0441\u0432\u043e\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0438 \u0440\u0435\u0448\u0438\u043b \u0438\u0437\u0443\u0447\u0438\u0442\u044c \u044d\u0442\u0443 \u0441\u0442\u043e\u0440\u043e\u043d\u0443 \u0432\u043e\u043f\u0440\u043e\u0441\u0430. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0438 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043b\u043e\u0430\u0434\u0435\u0440 \u0438 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <a href=\"https:\/\/github.com\/pkluz\/PKHUD\" rel=\"noopener noreferrer nofollow\">PKHUD<\/a>), \u043d\u043e \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u0432\u0435\u0441\u0435\u043b\u043e \u043f\u043e\u043a\u0430\u0441\u0442\u043e\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c!<\/p>\n<blockquote>\n<p><strong>\u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u043e\u0441\u044c \u043d\u0430 xcode 13.2.1, swift 5<\/strong><\/p>\n<\/blockquote>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/f58\/829\/f8f\/f58829f8fb8b4f1d0b5e1494a6795c7e.png\" alt=\"\u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 iOS UIActivityIndicator\" title=\"\u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 iOS UIActivityIndicator\" width=\"200\" height=\"200\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f58\/829\/f8f\/f58829f8fb8b4f1d0b5e1494a6795c7e.png\"\/><figcaption>\u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 iOS UIActivityIndicator<\/figcaption><\/figure>\n<h2>1. \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u0432\u043e\u0439 \u043f\u0440\u043e\u0441\u0442\u0435\u043d\u044c\u043a\u0438\u0439 \u0441\u043f\u0438\u043d\u043d\u0435\u0440<\/h2>\n<p>\u041c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u0432\u043e\u0439 \u043a\u043b\u0430\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 \u0421oreAnimations &#8212; \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0439 \u0438 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e. \u0418\u0437 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438: <\/p>\n<blockquote>\n<p><strong>\u0421oreAnimations<\/strong> \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u0432\u044b\u0441\u043e\u043a\u0443\u044e \u0447\u0430\u0441\u0442\u043e\u0442\u0443 \u043a\u0430\u0434\u0440\u043e\u0432 \u0438 \u043f\u043b\u0430\u0432\u043d\u0443\u044e \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044e, \u043d\u0435 \u043d\u0430\u0433\u0440\u0443\u0436\u0430\u044f \u0426\u041f \u0438 \u043d\u0435 \u0437\u0430\u043c\u0435\u0434\u043b\u044f\u044f \u0440\u0430\u0431\u043e\u0442\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0411\u043e\u043b\u044c\u0448\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u044b, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0430\u044f \u0434\u043b\u044f \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u0430\u0434\u0440\u0430 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0437\u0430 \u0432\u0430\u0441. \u0412\u044b \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0430\u044f \u0438 \u043a\u043e\u043d\u0435\u0447\u043d\u0430\u044f \u0442\u043e\u0447\u043a\u0438, \u0430 Core Animation \u0434\u0435\u043b\u0430\u0435\u0442 \u0432\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435, \u043f\u0435\u0440\u0435\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u044f \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0435 \u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043e\u0431\u043e\u0440\u0443\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u043b\u044f \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u044f \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430.<\/p>\n<\/blockquote>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u043c\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u0431\u0443\u0434\u0443\u0442 \u0434\u0432\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 CoreAnimations:<\/p>\n<p>1) <strong>CAShapeLayer<\/strong> &#8212; \u044d\u0442\u043e \u0441\u043b\u043e\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c \u043a\u0440\u0438\u0432\u044b\u0435 \u0411\u0435\u0437\u044c\u0435 UIBezierPath<\/p>\n<p>2) <strong>CAReplicatorLayer<\/strong> &#8212; \u044d\u0442\u043e \u0441\u043b\u043e\u0439, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043a\u043e\u043f\u0438\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u0441\u043b\u043e\u044f \u0441 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438, \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438 \u0438 \u0446\u0432\u0435\u0442\u043e\u0432\u044b\u043c\u0438 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f\u043c\u0438. <\/p>\n<p>\u0412\u043a\u0440\u0430\u0442\u0446\u0435: \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e UIBezierPath \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0438\u0433\u0443\u0440\u0443, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0435\u0435 \u043d\u0430 CAShapeLayer, \u0430 \u0437\u0430\u0442\u0435\u043c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 CAShapeLayer \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043d\u0430 CAReplicatorLayer, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 &#171;\u0440\u0430\u0441\u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c&#187; \u0438 \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u043c \u0432\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 (\u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043a\u043e\u043f\u0438\u0438 \u0431\u0443\u0434\u0443\u0442 \u043c\u0435\u043d\u044f\u0442\u044c <strong><em>\u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u044c<\/em><\/strong> \u0438 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u044d\u0444\u0444\u0435\u043a\u0442 \u0432\u0440\u0430\u0449\u0435\u043d\u0438\u044f).<\/p>\n<p>\u042f \u0441\u0440\u0430\u0437\u0443 \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u0434\u0430, \u0438 \u043e\u0442\u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u044e \u0435\u0433\u043e &#8212; \u0442\u0430\u043a\u043e\u0439 \u0441\u0442\u0438\u043b\u044c \u043f\u043e\u0432\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u043d\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0435 \u0447\u0435\u043c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u043a\u0443\u0441\u043a\u0438 \u043a\u043e\u0434\u0430 \u0441 \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u044f\u043c\u0438, \u0442. \u043a. \u0441\u0440\u0430\u0437\u0443 \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0435\u0431\u0435 \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c:<\/p>\n<pre><code class=\"swift\">final class CustomSpinnerSimple: UIView { \/\/ MARK: - Properties \/\/\/ \u041e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u043c \u043d\u0435\u0436\u043d\u044b\u0435 \u043d\u0430\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0434\u043b\u044f CAReplicatorLayer private lazy var replicatorLayer: CAReplicatorLayer = { let caLayer = CAReplicatorLayer() return caLayer }()  \/\/\/ \u0438 CAShapeLayer: private lazy var shapeLayer: CAShapeLayer = { let shapeLayer = CAShapeLayer() return shapeLayer }()  \/\/\/ \u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0434\u043b\u044f \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 (\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043d\u0438\u0436\u0435) private let keyAnimation = \"opacityAnimation\"  \/\/ MARK: - Init \/\/\/ \u0423\u0434\u043e\u0431\u043d\u044b\u0439 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \/\/\/ - Parameter squareLength: \u0434\u043b\u0438\u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0430(\u0432\u044c\u044e) \/\/\/ \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0441\u043f\u0438\u043d\u043d\u0435\u0440 \/\/\/ \u041f\u043e \u0443\u043c\u043f\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0441\u043f\u0438\u043d\u043d\u0435\u0440 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0446\u0435\u043d\u0442\u0440 \u044d\u043a\u0440\u0430\u043d\u0430 convenience init(squareLength: CGFloat) { let mainBounds = UIScreen.main.bounds let rect = CGRect(origin: CGPoint(x: (mainBounds.width-squareLength)\/2,   y: (mainBounds.height-squareLength)\/2),   size: CGSize(width: squareLength, height: squareLength)) self.init(frame: rect) }  \/\/\/ \u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u0447\u0435\u0440\u0435\u0437 frame, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u043f\u0438\u043d\u043d\u0435\u0440 \/\/\/ \u0432 \u043b\u044e\u0431\u043e\u0435 \u043c\u0435\u0441\u0442\u043e \u044d\u043a\u0440\u0430\u043d\u0430 \/\/\/ - Parameter frame: \u0444\u0440\u0435\u0439\u043c \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0441\u043f\u0438\u043d\u043d\u0435\u0440 override init(frame: CGRect) { super.init(frame: frame) \/\/ \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c replicatorLayer \u043d\u0430 \u0441\u043b\u043e\u0439 \u043d\u0430\u0448\u0435\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430: layer.addSublayer(replicatorLayer) \/\/ \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c shapeLayer \u043d\u0430 replicatorLayer: replicatorLayer.addSublayer(shapeLayer) }  \/\/\/ \u041e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440, \/\/\/ available(*, unavailable) - \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0447\u0442\u043e \u043e\u043d \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c\u0441\u044f \/\/\/\u0432 \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0435 \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 @available(*, unavailable) required init?(coder: NSCoder) { fatalError(\"init(coder:) has not been implemented\") }  override func layoutSubviews() { super.layoutSubviews() \/\/ \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e UIBezierPath \u0440\u0438\u0441\u0443\u0435\u043c \u043a\u0440\u0443\u0433 \u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c \/\/\/ \u043d\u0430 \u043d\u0430\u0448\u0435\u043c shapeLayer let size = min(bounds.width\/2, bounds.height\/2) let rect = CGRect(x: size\/4, y: size\/4, width: size\/4, height: size\/4) let path = UIBezierPath(ovalIn: rect) shapeLayer.path = path.cgPath  \/\/ \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u0434\u043b\u044f replicatorLayer replicatorLayer.frame = bounds replicatorLayer.position = CGPoint(x: size, y:  size) }  \/\/ MARK: - Animation's public functions  \/\/\/ \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 \/\/\/ - Parameters: \/\/\/   - delay: \u0412\u0440\u0435\u043c\u044f \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438, \u0447\u0435\u043c \u043c\u0435\u043d\u044c\u0448\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \/\/\/ \u0442\u0435\u043c \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0431\u0443\u0434\u0435\u0442 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044f \/\/\/   - replicates: \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0435\u043f\u043b\u0438\u043a, \u0442\u043e \u0435\u0441\u0442\u044c \u044d\u043a\u0437\u0435\u043c\u043b\u044f\u0440\u043e\u0432 \u043a\u043b\u0430\u0441\u0441\u0430 replicatorLayer func startAnimation(delay: TimeInterval, replicates: Int) { replicatorLayer.instanceCount = replicates replicatorLayer.instanceDelay = delay \/\/ \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u043b\u044f \u0440\u0435\u043f\u043b\u0438\u043a\u0438 - \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u0440\u0435\u043f\u043b\u0438\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \/\/ \u043f\u043e\u0432\u0435\u0440\u043d\u0443\u0442\u0430 \u043d\u0430 \u0443\u0433\u043e\u043b angle, \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 let angle = CGFloat(2.0 * Double.pi) \/ CGFloat(replicates) replicatorLayer.instanceTransform = CATransform3DMakeRotation(angle, 0.0, 0.0, 1.0)  \/\/ \u0410 \u0434\u0430\u043b\u0435\u0435 \u0441\u0430\u043c\u0430 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044f \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e shapeLayer: shapeLayer.opacity = 0 \/\/ \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u0438 \/\/ \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044f \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u0438: let opacityAnimation = CABasicAnimation(keyPath: \"opacity\") \/\/ \u043e\u0442 \u043a\u0430\u043a\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f (1 - \u043d\u0435\u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e, 0 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e) opacityAnimation.fromValue = 0.1 opacityAnimation.toValue = 0.8 \/\/ \u0434\u043e \u043a\u0430\u043a\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f  \/\/ \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c: opacityAnimation.duration = Double(replicates) * delay \/\/ \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0442\u044c \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e: opacityAnimation.repeatCount = Float.infinity \/\/ \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044e \u043a \u0441\u043b\u043e\u044e \u043f\u043e \u043a\u043b\u044e\u0447\u0443 keyAnimation: shapeLayer.add(opacityAnimation, forKey: keyAnimation) }  \/\/\/ \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 - \u0443\u0434\u0430\u043b\u044f\u0435\u043c \u0435\u0435 \u043f\u043e \u043a\u043b\u044e\u0447\u0443 keyAnimation \u0441 \u043d\u0430\u0448\u0435\u0433\u043e \u0441\u043b\u043e\u044f func stopAnimation() { guard shapeLayer.animation(forKey: keyAnimation) != nil else { return } shapeLayer.removeAnimation(forKey: keyAnimation) }  \/\/ MARK: - Deinit \/\/\/ \u041e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044e \u043f\u0440\u0438 \u0434\u0435\u0438\u043d\u0438\u0442\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 deinit { stopAnimation() } }<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435, \u0447\u0442\u043e\u0431\u044b \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u043a\u0430\u043a \u044d\u0442\u043e \u0432\u0441\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f, \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442, \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u043c \u0442\u0443\u0434\u0430 \u043a\u043b\u0430\u0441\u0441 <strong>CustomSpinnerSimple<\/strong> \u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440:<\/p>\n<pre><code class=\"swift\">final class ViewControllerSimple: UIViewController { \/\/ \u0421\u043f\u0438\u043d\u043d\u0435\u0440 - \u0440\u0430\u0437\u043c\u0435\u0440 100 private lazy var spinner: CustomSpinnerSimple = { let spinner = CustomSpinnerSimple(squareLength: 100) return spinner }()  \/\/ \u0412\u043e viewDidLoad \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e \u0441\u043f\u0438\u043d\u043d\u0435\u0440  \u0438 \u0441\u0442\u0430\u0440\u0442\u0443\u044e \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044e override func viewDidLoad() { super.viewDidLoad() view.addSubview(spinner) spinner.startAnimation(delay: 0.04, replicates: 20) } }<\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442, \u0432\u0438\u0434\u0438\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 &#8212; \u0432\u044b\u0448\u043b\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u0438\u043b\u0438\u0447\u043d\u043e! \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u043c\u0435\u043d\u044f\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b <strong><em>delay<\/em><\/strong>, <strong><em>replicates<\/em><\/strong> \u0438 <strong><em>opacityAnimation.fromValue<\/em><\/strong>, <strong><em>opacityAnimation.toValue <\/em><\/strong>\u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u0441\u043f\u0438\u043d\u043d\u0435\u0440\u044b, \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u044f \u043f\u0440\u0438\u0432\u0435\u043b \u043d\u0438\u0436\u0435:<\/p>\n<details class=\"spoiler\">\n<summary>\u041e\u0441\u0442\u043e\u0440\u043e\u0436\u043d\u043e, \u043e\u0447\u0435\u043d\u044c \u043a\u0440\u0430\u0441\u0438\u0432\u043e!<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/6a4\/14d\/bf7\/6a414dbf790ab9264b77a35daaafca03.gif\" alt=\"delay 0.04, replicates 20, fromValue 0.2, toValue 0.9\" title=\"delay 0.04, replicates 20, fromValue 0.2, toValue 0.9\" width=\"200\" height=\"200\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/6a4\/14d\/bf7\/6a414dbf790ab9264b77a35daaafca03.gif\"\/><figcaption>delay 0.04, replicates 20, fromValue 0.2, toValue 0.9<\/figcaption><\/figure>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/540\/deb\/454\/540deb45402dd051b8c0f1aac005dd26.gif\" alt=\"delay: 0.01, replicates: 120, fromValue 0.1, toValue 0.7\" title=\"delay: 0.01, replicates: 120, fromValue 0.1, toValue 0.7\" width=\"200\" height=\"200\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/540\/deb\/454\/540deb45402dd051b8c0f1aac005dd26.gif\"\/><figcaption>delay: 0.01, replicates: 120, fromValue 0.1, toValue 0.7<\/figcaption><\/figure>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/3d0\/834\/1de\/3d08341def218d0e742b51f58aab82cd.gif\" alt=\"delay: 0.04, replicates: 12, fromValue 0.1, toValue 0.9\" title=\"delay: 0.04, replicates: 12, fromValue 0.1, toValue 0.9\" width=\"200\" height=\"200\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/3d0\/834\/1de\/3d08341def218d0e742b51f58aab82cd.gif\"\/><figcaption>delay: 0.04, replicates: 12, fromValue 0.1, toValue 0.9<\/figcaption><\/figure>\n<\/div>\n<\/details>\n<h2>2. \u0423\u0441\u043b\u043e\u0436\u043d\u044f\u0435\u043c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 UIBezierPath<\/h2>\n<p>\u042f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0440\u0430\u0431\u043e\u0442\u0430\u043b \u043a\u043b\u0430\u0441\u0441 \u0441\u043f\u0438\u043d\u043d\u0435\u0440\u0430, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0432\u044c\u044e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440, \u0437\u0434\u0435\u0441\u044c \u043e\u043f\u0438\u0448\u0443 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u044b\u0435 \u0448\u0430\u0433\u0438 \u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b, \u0430 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435, \u0441\u0441\u044b\u043b\u043a\u0443 \u043e\u0441\u0442\u0430\u0432\u043b\u044e \u043d\u0438\u0436\u0435.<\/p>\n<p>\u0418\u0442\u0430\u043a, \u0432\u044b\u0448\u0435, \u0434\u043b\u044f \u043f\u043e\u0434\u043b\u043e\u0436\u043a\u0438 shapeLayer \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u043a\u0440\u0443\u0433, \u043a \u0442\u043e\u043c\u0443 \u0436\u0435 \u0441 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u043b\u0443\u0447\u0430\u044f <strong><em>width<\/em><\/strong> \u0438 <strong><em>height<\/em><\/strong>:<\/p>\n<pre><code class=\"swift\">let size = min(bounds.width\/2, bounds.height\/2) let rect = CGRect(x: size\/4, y: size\/4, width: size\/4, height: size\/4) let path = UIBezierPath(ovalIn: rect) shapeLayer.path = path.cgPath<\/code><\/pre>\n<p>\u0410 \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043f\u043e\u0439\u0442\u0438 \u0434\u0430\u043b\u044c\u0448\u0435? \u041f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u0435 \u0444\u0438\u0433\u0443\u0440\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e UIBezierPath, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0438\u0433\u0440\u0430\u0442\u044c \u0441 \u0440\u0430\u0437\u043c\u0435\u0440\u0430\u043c\u0438. \u042f \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0432\u0430\u0434\u0440\u0430\u0442 \u0438 \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a.<\/p>\n<p>\u041a\u0432\u0430\u0434\u0440\u0430\u0442 \u0440\u0438\u0441\u0443\u0435\u0442\u0441\u044f \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u043a\u0440\u0443\u0433\u0443:<\/p>\n<pre><code class=\"swift\">let size = min(bounds.width\/2, bounds.height\/2) let rect = CGRect(x: size\/4, y: size\/4, width: size\/4, height: size\/4) let path = UIBezierPath(rect: rect) shapeLayer.path = path.cgPath<\/code><\/pre>\n<p>\u0410 \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a \u0440\u0438\u0441\u0443\u0435\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043b\u0438\u043d\u0438\u0439, \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:<\/p>\n<pre><code class=\"swift\">var tX = bounds.width\/4 var tY = bounds.height\/4  let pathTriangle = CGMutablePath() let startPoint = CGPoint(x: bounds.width\/8, y: bounds.width\/8) pathTriangle.move(to: startPoint)  let point0 = startPoint.applying(.init(translationX: 0, y: tY \/ 2)) pathTriangle.move(to: point0)  let point1 = startPoint.applying(.init(translationX: tX, y: 0)) pathTriangle.addLine(to: point1)  let point2 = startPoint.applying(.init(translationX: tX, y: tY)) pathTriangle.addLine(to: point2)  pathTriangle.addLine(to: point0) shapeLayer.path = pathTriangle<\/code><\/pre>\n<p>\u042f \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043b <strong>CustomSpinnerSimple<\/strong>, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u0432 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0442\u0438\u043f \u0441\u043f\u0438\u043d\u043d\u0435\u0440\u0430 <strong>SpinnerType <\/strong>&#8212; \u044d\u0442\u043e \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435, \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0441\u0432\u043e\u0439 UIBezierPath(CGMutablePath \u0434\u043b\u044f \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u043e\u0432), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u0432\u0438\u0434 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438, \u043f\u043e\u043b\u0443\u0447\u0438\u0432 \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c \u043d\u0430 <strong>shapeLayer <\/strong>\u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0444\u0438\u0433\u0443\u0440\u044b.<\/p>\n<p>\u0414\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u0440\u0430\u0437\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u0441\u043f\u0438\u043d\u043d\u0435\u0440\u0430, \u0432\u043e \u0432\u044c\u044e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u044f \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u043b UICollectionView. <\/p>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435 \u0438\u0433\u0440\u0430\u044f\u0441\u044c \u0442\u0435\u043c\u0438 \u0436\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 <strong><em>delay<\/em><\/strong>, <strong><em>replicates<\/em><\/strong> &#8212; \u044f \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043b \u0440\u0430\u043d\u0434\u043e\u043c\u043d\u0443\u044e \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u044d\u0442\u0438\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 tX \u0438 tY, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u043b\u0438\u044f\u044e\u0442 \u043d\u0430 \u0440\u0430\u0437\u043c\u0435\u0440, \u0430 \u0434\u043b\u044f \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a \u0438 \u043d\u0430 \u043e\u0431\u0449\u0438\u0439 \u0432\u0438\u0434, \u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u0446\u0435\u043b\u0443\u044e \u0433\u0430\u043c\u043c\u0443 \u043d\u043e\u0432\u044b\u0445 \u0441\u043f\u0438\u043d\u043d\u0435\u0440\u043e\u0432:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/742\/234\/a72\/742234a72d28873067e17cfdf5249dbc.gif\" alt=\"\u041d\u043e\u0432\u044b\u0435 \u0441\u043f\u0438\u043d\u043d\u0435\u0440\u044b \u0441 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 CGMutablePath \u0438 UIBezierPath\" title=\"\u041d\u043e\u0432\u044b\u0435 \u0441\u043f\u0438\u043d\u043d\u0435\u0440\u044b \u0441 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 CGMutablePath \u0438 UIBezierPath\" width=\"800\" height=\"1068\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/742\/234\/a72\/742234a72d28873067e17cfdf5249dbc.gif\"\/><figcaption>\u041d\u043e\u0432\u044b\u0435 \u0441\u043f\u0438\u043d\u043d\u0435\u0440\u044b \u0441 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 CGMutablePath \u0438 UIBezierPath<\/figcaption><\/figure>\n<p>\u041c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0446\u0432\u0435\u0442 \u043a \u043d\u0430\u0448\u0438\u043c \u0441\u043f\u0438\u043d\u043d\u0435\u0440\u0430\u043c, \u043e\u043d \u0442\u0430\u043a\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u043d\u0434\u043e\u043c\u043d\u044b\u0439:<\/p>\n<pre><code class=\"swift\">shapeLayer.fillColor = UIColor.random.cgColor<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 UIColor:<\/p>\n<pre><code class=\"swift\">extension UIColor { static var random: UIColor { return UIColor( red: .random(in: 0...1), green: .random(in: 0...1), blue: .random(in: 0...1), alpha: 1.0 ) } }<\/code><\/pre>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0447\u0442\u043e \u0442\u043e \u0432\u0440\u043e\u0434\u0435 \u044d\u0442\u043e\u0433\u043e:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/2aa\/eb9\/303\/2aaeb9303d91216584e19dcad9bbe3a0.gif\" alt=\"\u0426\u0432\u0435\u0442\u043d\u044b\u0435 \u0441\u043f\u0438\u043d\u043d\u0435\u0440\u044b\" title=\"\u0426\u0432\u0435\u0442\u043d\u044b\u0435 \u0441\u043f\u0438\u043d\u043d\u0435\u0440\u044b\" width=\"800\" height=\"1073\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2aa\/eb9\/303\/2aaeb9303d91216584e19dcad9bbe3a0.gif\"\/><figcaption>\u0426\u0432\u0435\u0442\u043d\u044b\u0435 \u0441\u043f\u0438\u043d\u043d\u0435\u0440\u044b<\/figcaption><\/figure>\n<h2>3. \u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0421\u043e\u0433\u043b\u0430\u0441\u0438\u0442\u0435\u0441\u044c, \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0432\u0435\u0441\u0435\u043b\u043e\u0435 \u043f\u0440\u0438\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u0432\u0441\u0435\u0433\u043e \u0434\u0432\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 <strong>\u0421oreAnimations<\/strong>. \u041e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 &#8212; \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b UIKit.<\/p>\n<p>\u0414\u0443\u043c\u0430\u044e \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u043a\u0443\u0434\u0430 \u043a\u043e\u043f\u0430\u0442\u044c, \u0435\u0441\u043b\u0438 \u0437\u0430\u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u0441\u043f\u0438\u043d\u043d\u0435\u0440. \u041c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c \u0438 \u043d\u0430\u0439\u0442\u0438 \u043d\u043e\u0432\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u0441\u043f\u0438\u043d\u043d\u0435\u0440\u044b &#8212; \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0432 \u043d\u043e\u0432\u044b\u0439 UIBezierPath, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0438\u0433\u0440\u0430\u0432 \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438, \u043f\u0440\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044f \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043b \u0432\u044b\u0448\u0435.<\/p>\n<p>\u041a\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c <a href=\"https:\/\/github.com\/AlexanderGermek\/CustomSpinnerUIKit\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>. \u0412 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0434\u0432\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043f\u0430\u043f\u043a\u0438 &#8212; Simple \u0438 Hard. \u041f\u0435\u0440\u0432\u0430\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0441\u043f\u0438\u043d\u043d\u0435\u0440\u0443 \u0438 \u0432\u044c\u044e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u043b \u0432 \u043f\u0443\u043d\u043a\u0442\u0435 1. \u0412\u0442\u043e\u0440\u0430\u044f &#8212; \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u043c \u0441\u043f\u0438\u043d\u043d\u0435\u0440\u0430\u043c \u0438\u0437 \u043f\u0443\u043d\u043a\u0442\u0430 2 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438. \u041f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u0441\u044f \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0432 \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u044b\u0439 \u0432\u044c\u044e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a71\/f8d\/73a\/a71f8d73a516e442db9deb66958c866c.png\" alt=\"ViewController \u0434\u043b\u044f Hard, ViewControllerSimple \u0434\u043b\u044f Simple\" title=\"ViewController \u0434\u043b\u044f Hard, ViewControllerSimple \u0434\u043b\u044f Simple\" width=\"512\" height=\"284\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a71\/f8d\/73a\/a71f8d73a516e442db9deb66958c866c.png\"\/><figcaption>ViewController \u0434\u043b\u044f Hard, ViewControllerSimple \u0434\u043b\u044f Simple<\/figcaption><\/figure>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/658083\/\"> https:\/\/habr.com\/ru\/post\/658083\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<h2>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0412\u0441\u0435 \u043c\u044b \u0437\u043d\u0430\u0435\u043c \u043a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0438\u043d\u0434\u0438\u043a\u0430\u0442\u043e\u0440 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 (\u0434\u0430\u043b\u0435\u0435 &#8212; \u0441\u043f\u0438\u043d\u043d\u0435\u0440 \u0438\u043b\u0438 \u043b\u043e\u0430\u0434\u0435\u0440) \u043d\u0430 \u043d\u0430\u0448\u0438\u0445 iOS \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u043a\u0435\u0439\u0441\u0430\u0445, \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0432\u044b\u043d\u0443\u0436\u0434\u0435\u043d \u0436\u0434\u0430\u0442\u044c \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u0435 \u043a\u0430\u043a\u043e\u0433\u043e-\u043b\u0438\u0431\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430. \u041d\u043e \u043c\u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u044b\u043b\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 \u043b\u043e\u0430\u0434\u0435\u0440, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u0435\u0433\u043e \u0432 \u0441\u0432\u043e\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0438 \u0440\u0435\u0448\u0438\u043b \u0438\u0437\u0443\u0447\u0438\u0442\u044c \u044d\u0442\u0443 \u0441\u0442\u043e\u0440\u043e\u043d\u0443 \u0432\u043e\u043f\u0440\u043e\u0441\u0430. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0438 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043b\u043e\u0430\u0434\u0435\u0440 \u0438 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <a href=\"https:\/\/github.com\/pkluz\/PKHUD\" rel=\"noopener noreferrer nofollow\">PKHUD<\/a>), \u043d\u043e \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u0432\u0435\u0441\u0435\u043b\u043e \u043f\u043e\u043a\u0430\u0441\u0442\u043e\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c!<\/p>\n<blockquote>\n<p><strong>\u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u043e\u0441\u044c \u043d\u0430 xcode 13.2.1, swift 5<\/strong><\/p>\n<\/blockquote>\n<figure class=\"\"><figcaption>\u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 iOS UIActivityIndicator<\/figcaption><\/figure>\n<h2>1. \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u0432\u043e\u0439 \u043f\u0440\u043e\u0441\u0442\u0435\u043d\u044c\u043a\u0438\u0439 \u0441\u043f\u0438\u043d\u043d\u0435\u0440<\/h2>\n<p>\u041c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u0432\u043e\u0439 \u043a\u043b\u0430\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 \u0421oreAnimations &#8212; \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0439 \u0438 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e. \u0418\u0437 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438: <\/p>\n<blockquote>\n<p><strong>\u0421oreAnimations<\/strong> \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u0432\u044b\u0441\u043e\u043a\u0443\u044e \u0447\u0430\u0441\u0442\u043e\u0442\u0443 \u043a\u0430\u0434\u0440\u043e\u0432 \u0438 \u043f\u043b\u0430\u0432\u043d\u0443\u044e \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044e, \u043d\u0435 \u043d\u0430\u0433\u0440\u0443\u0436\u0430\u044f \u0426\u041f \u0438 \u043d\u0435 \u0437\u0430\u043c\u0435\u0434\u043b\u044f\u044f \u0440\u0430\u0431\u043e\u0442\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0411\u043e\u043b\u044c\u0448\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u044b, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0430\u044f \u0434\u043b\u044f \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u0430\u0434\u0440\u0430 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0437\u0430 \u0432\u0430\u0441. \u0412\u044b \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0430\u044f \u0438 \u043a\u043e\u043d\u0435\u0447\u043d\u0430\u044f \u0442\u043e\u0447\u043a\u0438, \u0430 Core Animation \u0434\u0435\u043b\u0430\u0435\u0442 \u0432\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435, \u043f\u0435\u0440\u0435\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u044f \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0435 \u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043e\u0431\u043e\u0440\u0443\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u043b\u044f \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u044f \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430.<\/p>\n<\/blockquote>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u043c\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u0431\u0443\u0434\u0443\u0442 \u0434\u0432\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 CoreAnimations:<\/p>\n<p>1) <strong>CAShapeLayer<\/strong> &#8212; \u044d\u0442\u043e \u0441\u043b\u043e\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c \u043a\u0440\u0438\u0432\u044b\u0435 \u0411\u0435\u0437\u044c\u0435 UIBezierPath<\/p>\n<p>2) <strong>CAReplicatorLayer<\/strong> &#8212; \u044d\u0442\u043e \u0441\u043b\u043e\u0439, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043a\u043e\u043f\u0438\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u0441\u043b\u043e\u044f \u0441 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438, \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438 \u0438 \u0446\u0432\u0435\u0442\u043e\u0432\u044b\u043c\u0438 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f\u043c\u0438. <\/p>\n<p>\u0412\u043a\u0440\u0430\u0442\u0446\u0435: \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e UIBezierPath \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0438\u0433\u0443\u0440\u0443, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0435\u0435 \u043d\u0430 CAShapeLayer, \u0430 \u0437\u0430\u0442\u0435\u043c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 CAShapeLayer \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043d\u0430 CAReplicatorLayer, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 &#171;\u0440\u0430\u0441\u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c&#187; \u0438 \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u043c \u0432\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 (\u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043a\u043e\u043f\u0438\u0438 \u0431\u0443\u0434\u0443\u0442 \u043c\u0435\u043d\u044f\u0442\u044c <strong><em>\u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u044c<\/em><\/strong> \u0438 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u044d\u0444\u0444\u0435\u043a\u0442 \u0432\u0440\u0430\u0449\u0435\u043d\u0438\u044f).<\/p>\n<p>\u042f \u0441\u0440\u0430\u0437\u0443 \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u0434\u0430, \u0438 \u043e\u0442\u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u044e \u0435\u0433\u043e &#8212; \u0442\u0430\u043a\u043e\u0439 \u0441\u0442\u0438\u043b\u044c \u043f\u043e\u0432\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u043d\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0435 \u0447\u0435\u043c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u043a\u0443\u0441\u043a\u0438 \u043a\u043e\u0434\u0430 \u0441 \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u044f\u043c\u0438, \u0442. \u043a. \u0441\u0440\u0430\u0437\u0443 \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0435\u0431\u0435 \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c:<\/p>\n<pre><code class=\"swift\">final class CustomSpinnerSimple: UIView { \/\/ MARK: - Properties \/\/\/ \u041e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u043c \u043d\u0435\u0436\u043d\u044b\u0435 \u043d\u0430\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0434\u043b\u044f CAReplicatorLayer private lazy var replicatorLayer: CAReplicatorLayer = { let caLayer = CAReplicatorLayer() return caLayer }()  \/\/\/ \u0438 CAShapeLayer: private lazy var shapeLayer: CAShapeLayer = { let shapeLayer = CAShapeLayer() return shapeLayer }()  \/\/\/ \u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0434\u043b\u044f \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 (\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043d\u0438\u0436\u0435) private let keyAnimation = \"opacityAnimation\"  \/\/ MARK: - Init \/\/\/ \u0423\u0434\u043e\u0431\u043d\u044b\u0439 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \/\/\/ - Parameter squareLength: \u0434\u043b\u0438\u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0430(\u0432\u044c\u044e) \/\/\/ \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0441\u043f\u0438\u043d\u043d\u0435\u0440 \/\/\/ \u041f\u043e \u0443\u043c\u043f\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0441\u043f\u0438\u043d\u043d\u0435\u0440 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0446\u0435\u043d\u0442\u0440 \u044d\u043a\u0440\u0430\u043d\u0430 convenience init(squareLength: CGFloat) { let mainBounds = UIScreen.main.bounds let rect = CGRect(origin: CGPoint(x: (mainBounds.width-squareLength)\/2,   y: (mainBounds.height-squareLength)\/2),   size: CGSize(width: squareLength, height: squareLength)) self.init(frame: rect) }  \/\/\/ \u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u0447\u0435\u0440\u0435\u0437 frame, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u043f\u0438\u043d\u043d\u0435\u0440 \/\/\/ \u0432 \u043b\u044e\u0431\u043e\u0435 \u043c\u0435\u0441\u0442\u043e \u044d\u043a\u0440\u0430\u043d\u0430 \/\/\/ - Parameter frame: \u0444\u0440\u0435\u0439\u043c \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0441\u043f\u0438\u043d\u043d\u0435\u0440 override init(frame: CGRect) { super.init(frame: frame) \/\/ \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c replicatorLayer \u043d\u0430 \u0441\u043b\u043e\u0439 \u043d\u0430\u0448\u0435\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430: layer.addSublayer(replicatorLayer) \/\/ \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c shapeLayer \u043d\u0430 replicatorLayer: replicatorLayer.addSublayer(shapeLayer) }  \/\/\/ \u041e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440, \/\/\/ available(*, unavailable) - \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0447\u0442\u043e \u043e\u043d \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c\u0441\u044f \/\/\/\u0432 \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0435 \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 @available(*, unavailable) required init?(coder: NSCoder) { fatalError(\"init(coder:) has not been implemented\") }  override func layoutSubviews() { super.layoutSubviews() \/\/ \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e UIBezierPath \u0440\u0438\u0441\u0443\u0435\u043c \u043a\u0440\u0443\u0433 \u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c \/\/\/ \u043d\u0430 \u043d\u0430\u0448\u0435\u043c shapeLayer let size = min(bounds.width\/2, bounds.height\/2) let rect = CGRect(x: size\/4, y: size\/4, width: size\/4, height: size\/4) let path = UIBezierPath(ovalIn: rect) shapeLayer.path = path.cgPath  \/\/ \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u0434\u043b\u044f replicatorLayer replicatorLayer.frame = bounds replicatorLayer.position = CGPoint(x: size, y:  size) }  \/\/ MARK: - Animation's public functions  \/\/\/ \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 \/\/\/ - Parameters: \/\/\/   - delay: \u0412\u0440\u0435\u043c\u044f \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438, \u0447\u0435\u043c \u043c\u0435\u043d\u044c\u0448\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \/\/\/ \u0442\u0435\u043c \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0431\u0443\u0434\u0435\u0442 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044f \/\/\/   - replicates: \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0435\u043f\u043b\u0438\u043a, \u0442\u043e \u0435\u0441\u0442\u044c \u044d\u043a\u0437\u0435\u043c\u043b\u044f\u0440\u043e\u0432 \u043a\u043b\u0430\u0441\u0441\u0430 replicatorLayer func startAnimation(delay: TimeInterval, replicates: Int) { replicatorLayer.instanceCount = replicates replicatorLayer.instanceDelay = delay \/\/ \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u043b\u044f \u0440\u0435\u043f\u043b\u0438\u043a\u0438 - \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u0440\u0435\u043f\u043b\u0438\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \/\/ \u043f\u043e\u0432\u0435\u0440\u043d\u0443\u0442\u0430 \u043d\u0430 \u0443\u0433\u043e\u043b angle, \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 let angle = CGFloat(2.0 * Double.pi) \/ CGFloat(replicates) replicatorLayer.instanceTransform = CATransform3DMakeRotation(angle, 0.0, 0.0, 1.0)  \/\/ \u0410 \u0434\u0430\u043b\u0435\u0435 \u0441\u0430\u043c\u0430 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044f \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e shapeLayer: shapeLayer.opacity = 0 \/\/ \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u0438 \/\/ \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044f \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u0438: let opacityAnimation = CABasicAnimation(keyPath: \"opacity\") \/\/ \u043e\u0442 \u043a\u0430\u043a\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f (1 - \u043d\u0435\u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e, 0 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e) opacityAnimation.fromValue = 0.1 opacityAnimation.toValue = 0.8 \/\/ \u0434\u043e \u043a\u0430\u043a\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f  \/\/ \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c: opacityAnimation.duration = Double(replicates) * delay \/\/ \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0442\u044c \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e: opacityAnimation.repeatCount = Float.infinity \/\/ \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044e \u043a \u0441\u043b\u043e\u044e \u043f\u043e \u043a\u043b\u044e\u0447\u0443 keyAnimation: shapeLayer.add(opacityAnimation, forKey: keyAnimation) }  \/\/\/ \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 - \u0443\u0434\u0430\u043b\u044f\u0435\u043c \u0435\u0435 \u043f\u043e \u043a\u043b\u044e\u0447\u0443 keyAnimation \u0441 \u043d\u0430\u0448\u0435\u0433\u043e \u0441\u043b\u043e\u044f func stopAnimation() { guard shapeLayer.animation(forKey: keyAnimation) != nil else { return } shapeLayer.removeAnimation(forKey: keyAnimation) }  \/\/ MARK: - Deinit \/\/\/ \u041e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044e \u043f\u0440\u0438 \u0434\u0435\u0438\u043d\u0438\u0442\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 deinit { stopAnimation() } }<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435, \u0447\u0442\u043e\u0431\u044b \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u043a\u0430\u043a \u044d\u0442\u043e \u0432\u0441\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f, \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442, \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u043c \u0442\u0443\u0434\u0430 \u043a\u043b\u0430\u0441\u0441 <strong>CustomSpinnerSimple<\/strong> \u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440:<\/p>\n<pre><code class=\"swift\">final class ViewControllerSimple: UIViewController { \/\/ \u0421\u043f\u0438\u043d\u043d\u0435\u0440 - \u0440\u0430\u0437\u043c\u0435\u0440 100 private lazy var spinner: CustomSpinnerSimple = { let spinner = CustomSpinnerSimple(squareLength: 100) return spinner }()  \/\/ \u0412\u043e viewDidLoad \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e \u0441\u043f\u0438\u043d\u043d\u0435\u0440  \u0438 \u0441\u0442\u0430\u0440\u0442\u0443\u044e \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044e override func viewDidLoad() { super.viewDidLoad() view.addSubview(spinner) spinner.startAnimation(delay: 0.04, replicates: 20) } }<\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442, \u0432\u0438\u0434\u0438\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 &#8212; \u0432\u044b\u0448\u043b\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u0438\u043b\u0438\u0447\u043d\u043e! \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u043c\u0435\u043d\u044f\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b <strong><em>delay<\/em><\/strong>, <strong><em>replicates<\/em><\/strong> \u0438 <strong><em>opacityAnimation.fromValue<\/em><\/strong>, <strong><em>opacityAnimation.toValue <\/em><\/strong>\u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u0441\u043f\u0438\u043d\u043d\u0435\u0440\u044b, \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u044f \u043f\u0440\u0438\u0432\u0435\u043b \u043d\u0438\u0436\u0435:<\/p>\n<details class=\"spoiler\">\n<summary>\u041e\u0441\u0442\u043e\u0440\u043e\u0436\u043d\u043e, \u043e\u0447\u0435\u043d\u044c \u043a\u0440\u0430\u0441\u0438\u0432\u043e!<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"\"><figcaption>delay 0.04, replicates 20, fromValue 0.2, toValue 0.9<\/figcaption><\/figure>\n<figure class=\"\"><figcaption>delay: 0.01, replicates: 120, fromValue 0.1, toValue 0.7<\/figcaption><\/figure>\n<figure class=\"\"><figcaption>delay: 0.04, replicates: 12, fromValue 0.1, toValue 0.9<\/figcaption><\/figure>\n<\/div>\n<\/details>\n<h2>2. \u0423\u0441\u043b\u043e\u0436\u043d\u044f\u0435\u043c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 UIBezierPath<\/h2>\n<p>\u042f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0440\u0430\u0431\u043e\u0442\u0430\u043b \u043a\u043b\u0430\u0441\u0441 \u0441\u043f\u0438\u043d\u043d\u0435\u0440\u0430, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0432\u044c\u044e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440, \u0437\u0434\u0435\u0441\u044c \u043e\u043f\u0438\u0448\u0443 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u044b\u0435 \u0448\u0430\u0433\u0438 \u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b, \u0430 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435, \u0441\u0441\u044b\u043b\u043a\u0443 \u043e\u0441\u0442\u0430\u0432\u043b\u044e \u043d\u0438\u0436\u0435.<\/p>\n<p>\u0418\u0442\u0430\u043a, \u0432\u044b\u0448\u0435, \u0434\u043b\u044f \u043f\u043e\u0434\u043b\u043e\u0436\u043a\u0438 shapeLayer \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u043a\u0440\u0443\u0433, \u043a \u0442\u043e\u043c\u0443 \u0436\u0435 \u0441 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u043b\u0443\u0447\u0430\u044f <strong><em>width<\/em><\/strong> \u0438 <strong><em>height<\/em><\/strong>:<\/p>\n<pre><code class=\"swift\">let size = min(bounds.width\/2, bounds.height\/2) let rect = CGRect(x: size\/4, y: size\/4, width: size\/4, height: size\/4) let path = UIBezierPath(ovalIn: rect) shapeLayer.path = path.cgPath<\/code><\/pre>\n<p>\u0410 \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043f\u043e\u0439\u0442\u0438 \u0434\u0430\u043b\u044c\u0448\u0435? \u041f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u0435 \u0444\u0438\u0433\u0443\u0440\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e UIBezierPath, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0438\u0433\u0440\u0430\u0442\u044c \u0441 \u0440\u0430\u0437\u043c\u0435\u0440\u0430\u043c\u0438. \u042f \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0432\u0430\u0434\u0440\u0430\u0442 \u0438 \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a.<\/p>\n<p>\u041a\u0432\u0430\u0434\u0440\u0430\u0442 \u0440\u0438\u0441\u0443\u0435\u0442\u0441\u044f \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u043a\u0440\u0443\u0433\u0443:<\/p>\n<pre><code class=\"swift\">let size = min(bounds.width\/2, bounds.height\/2) let rect = CGRect(x: size\/4, y: size\/4, width: size\/4, height: size\/4) let path = UIBezierPath(rect: rect) shapeLayer.path = path.cgPath<\/code><\/pre>\n<p>\u0410 \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a \u0440\u0438\u0441\u0443\u0435\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043b\u0438\u043d\u0438\u0439, \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:<\/p>\n<pre><code class=\"swift\">var tX = bounds.width\/4 var tY = bounds.height\/4  let pathTriangle = CGMutablePath() let startPoint = CGPoint(x: bounds.width\/8, y: bounds.width\/8) pathTriangle.move(to: startPoint)  let point0 = startPoint.applying(.init(translationX: 0, y: tY \/ 2)) pathTriangle.move(to: point0)  let point1 = startPoint.applying(.init(translationX: tX, y: 0)) pathTriangle.addLine(to: point1)  let point2 = startPoint.applying(.init(translationX: tX, y: tY)) pathTriangle.addLine(to: point2)  pathTriangle.addLine(to: point0) shapeLayer.path = pathTriangle<\/code><\/pre>\n<p>\u042f \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043b <strong>CustomSpinnerSimple<\/strong>, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u0432 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0442\u0438\u043f \u0441\u043f\u0438\u043d\u043d\u0435\u0440\u0430 <strong>SpinnerType <\/strong>&#8212; \u044d\u0442\u043e \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435, \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0441\u0432\u043e\u0439 UIBezierPath(CGMutablePath \u0434\u043b\u044f \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u043e\u0432), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u0432\u0438\u0434 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438, \u043f\u043e\u043b\u0443\u0447\u0438\u0432 \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c \u043d\u0430 <strong>shapeLayer <\/strong>\u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0444\u0438\u0433\u0443\u0440\u044b.<\/p>\n<p>\u0414\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u0440\u0430\u0437\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u0441\u043f\u0438\u043d\u043d\u0435\u0440\u0430, \u0432\u043e \u0432\u044c\u044e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u044f \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u043b UICollectionView. <\/p>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435 \u0438\u0433\u0440\u0430\u044f\u0441\u044c \u0442\u0435\u043c\u0438 \u0436\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 <strong><em>delay<\/em><\/strong>, <strong><em>replicates<\/em><\/strong> &#8212; \u044f \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043b \u0440\u0430\u043d\u0434\u043e\u043c\u043d\u0443\u044e \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u044d\u0442\u0438\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 tX \u0438 tY, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u043b\u0438\u044f\u044e\u0442 \u043d\u0430 \u0440\u0430\u0437\u043c\u0435\u0440, \u0430 \u0434\u043b\u044f \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a \u0438 \u043d\u0430 \u043e\u0431\u0449\u0438\u0439 \u0432\u0438\u0434, \u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u0446\u0435\u043b\u0443\u044e \u0433\u0430\u043c\u043c\u0443 \u043d\u043e\u0432\u044b\u0445 \u0441\u043f\u0438\u043d\u043d\u0435\u0440\u043e\u0432:<\/p>\n<figure class=\"full-width\"><figcaption>\u041d\u043e\u0432\u044b\u0435 \u0441\u043f\u0438\u043d\u043d\u0435\u0440\u044b \u0441 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 CGMutablePath \u0438 UIBezierPath<\/figcaption><\/figure>\n<p>\u041c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0446\u0432\u0435\u0442 \u043a \u043d\u0430\u0448\u0438\u043c \u0441\u043f\u0438\u043d\u043d\u0435\u0440\u0430\u043c, \u043e\u043d \u0442\u0430\u043a\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u043d\u0434\u043e\u043c\u043d\u044b\u0439:<\/p>\n<pre><code class=\"swift\">shapeLayer.fillColor = UIColor.random.cgColor<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 UIColor:<\/p>\n<pre><code class=\"swift\">extension UIColor { static var random: UIColor { return UIColor( red: .random(in: 0...1), green: .random(in: 0...1), blue: .random(in: 0...1), alpha: 1.0 ) } }<\/code><\/pre>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0447\u0442\u043e \u0442\u043e \u0432\u0440\u043e\u0434\u0435 \u044d\u0442\u043e\u0433\u043e:<\/p>\n<figure class=\"full-width\"><figcaption>\u0426\u0432\u0435\u0442\u043d\u044b\u0435 \u0441\u043f\u0438\u043d\u043d\u0435\u0440\u044b<\/figcaption><\/figure>\n<h2>3. \u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0421\u043e\u0433\u043b\u0430\u0441\u0438\u0442\u0435\u0441\u044c, \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0432\u0435\u0441\u0435\u043b\u043e\u0435 \u043f\u0440\u0438\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u0432\u0441\u0435\u0433\u043e \u0434\u0432\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 <strong>\u0421oreAnimations<\/strong>. \u041e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 &#8212; \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b UIKit.<\/p>\n<p>\u0414\u0443\u043c\u0430\u044e \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u043a\u0443\u0434\u0430 \u043a\u043e\u043f\u0430\u0442\u044c, \u0435\u0441\u043b\u0438 \u0437\u0430\u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u0441\u043f\u0438\u043d\u043d\u0435\u0440. \u041c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c \u0438 \u043d\u0430\u0439\u0442\u0438 \u043d\u043e\u0432\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u0441\u043f\u0438\u043d\u043d\u0435\u0440\u044b &#8212; \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0432 \u043d\u043e\u0432\u044b\u0439 UIBezierPath, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0438\u0433\u0440\u0430\u0432 \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438, \u043f\u0440\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044f \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043b \u0432\u044b\u0448\u0435.<\/p>\n<p>\u041a\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c <a href=\"https:\/\/github.com\/AlexanderGermek\/CustomSpinnerUIKit\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>. \u0412 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0434\u0432\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043f\u0430\u043f\u043a\u0438 &#8212; Simple \u0438 Hard. \u041f\u0435\u0440\u0432\u0430\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0441\u043f\u0438\u043d\u043d\u0435\u0440\u0443 \u0438 \u0432\u044c\u044e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u043b \u0432 \u043f\u0443\u043d\u043a\u0442\u0435 1. \u0412\u0442\u043e\u0440\u0430\u044f &#8212; \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u043c \u0441\u043f\u0438\u043d\u043d\u0435\u0440\u0430\u043c \u0438\u0437 \u043f\u0443\u043d\u043a\u0442\u0430 2 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438. \u041f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u0441\u044f \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0432 \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u044b\u0439 \u0432\u044c\u044e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f:<\/p>\n<figure class=\"\"><figcaption>ViewController \u0434\u043b\u044f Hard, ViewControllerSimple \u0434\u043b\u044f Simple<\/figcaption><\/figure>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/658083\/\"> https:\/\/habr.com\/ru\/post\/658083\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-331424","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/331424","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=331424"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/331424\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=331424"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=331424"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=331424"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}