{"id":392165,"date":"2024-06-29T10:15:28","date_gmt":"2024-06-29T10:15:28","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=392165"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2024-06-29T10:15:28","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=392165","title":{"rendered":"<span>\u041a\u0430\u043a \u044f \u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u043b \u0432 \u043a\u043e\u043d\u043a\u0443\u0440\u0441\u0435 Telegram \u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043c\u0435\u0434\u0438\u0430\u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0430 \u0438 \u0437\u0430\u043d\u044f\u043b \u043d\u0438\u043a\u0430\u043a\u043e\u0435 \u043c\u0435\u0441\u0442\u043e (\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u0431\u0435\u0441\u0446\u0435\u043d\u043d\u044b\u0439 \u043e\u043f\u044b\u0442?)<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a06\/1f5\/03b\/a061f503bce4df062908de16ba0861af.png\" alt=\"\u041a\u043e\u043d\u043a\u0443\u0440\u0441 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c \u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043c\u0435\u0434\u0438\u0430\u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0430\" title=\"\u041a\u043e\u043d\u043a\u0443\u0440\u0441 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c \u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043c\u0435\u0434\u0438\u0430\u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0430\" width=\"1920\" height=\"1083\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a06\/1f5\/03b\/a061f503bce4df062908de16ba0861af.png\"\/><figcaption>\u041a\u043e\u043d\u043a\u0443\u0440\u0441 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c \u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043c\u0435\u0434\u0438\u0430\u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0430<\/figcaption><\/figure>\n<p>\u0417\u0430\u0434\u0430\u0447\u0430 \u0441\u043e\u0441\u0442\u043e\u044f\u043b\u0430 \u0432 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0430\u0432\u0442\u043e\u043d\u043e\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u0435\u0434\u0438\u0430\u0444\u0430\u0439\u043b\u043e\u0432 \u043d\u0430 Swift <strong>\u0431\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0445 UI-\u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u0432<\/strong>. \u041a\u043e\u043d\u043a\u0443\u0440\u0441\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u044b \u0441 \u043d\u0443\u043b\u044f. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439 \u043c\u0435\u0434\u0438\u0430\u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u043e\u0432 \u0441 \u043f\u043e\u0445\u043e\u0436\u0438\u043c\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438 \u0441\u0442\u0440\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u0435\u0449\u0435\u043d\u043e. <\/p>\n<p>\u041f\u043b\u0430\u0432\u043d\u043e\u0441\u0442\u044c \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 \u0438 \u043e\u0431\u0449\u0430\u044f \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0443\u0442 \u0438\u0433\u0440\u0430\u0442\u044c \u0432\u0430\u0436\u043d\u0443\u044e \u0440\u043e\u043b\u044c. \u0418 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435, \u043d\u043e \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 \u0432\u0430\u0436\u043d\u043e\u0435 \u2014 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u043e\u0432 (\u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0441\u0431\u043e\u0438, \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e, \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b, \u0437\u0430\u043c\u0435\u0442\u043d\u043e\u0435 \u043c\u0438\u0433\u0430\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u043d\u0435\u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u0441\u0442\u0432\u043e \u043c\u0430\u043a\u0435\u0442\u0430 \u0438 \u043c\u043d\u043e\u0433\u043e\u0435 \u0434\u0440\u0443\u0433\u043e\u0435).<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0443\u0437\u043d\u0430\u0442\u044c, \u0447\u0442\u043e \u0436\u0435 \u0431\u044b\u043b\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043e, \u043a\u0430\u043a\u0438\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u0438 \u0432\u044b\u0432\u043e\u0434\u044b \u044f \u0441\u0434\u0435\u043b\u0430\u043b \u043f\u043e\u0441\u043b\u0435 \u043a\u043e\u043d\u043a\u0443\u0440\u0441\u0430, \u0442\u043e \u0437\u0430\u0445\u043e\u0434\u0438\u0442\u0435. <\/p>\n<p><strong>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/strong>. \u0415\u0441\u043b\u0438 \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0439, \u0442\u043e\u00a0<a href=\"https:\/\/t.me\/+qll_YZ6_8bo2Njky\" rel=\"noopener noreferrer nofollow\">\u0432\u043e\u0442 \u0442\u0443\u0442 \u044f \u043f\u0438\u0448\u0443 \u043e\u0431 iOS-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435<\/a>\u00a0\u0438 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0441 \u043d\u0435\u0439 \u0441\u0432\u044f\u0437\u0430\u043d\u043e.<\/p>\n<hr\/>\n<h2>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u0438 \u043e\u0446\u0435\u043d\u043a\u0430 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u0441\u0438\u043b \u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439<\/h2>\n<p>\u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0439 \u044f\u0432\u043b\u044f\u043b\u0430\u0441\u044c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 iOS 13 \u0438 \u0432\u044b\u0448\u0435, \u0442\u043e \u043c\u043d\u043e\u0433\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0430, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u0432\u044b\u0431\u043e\u0440\u0430 \u0446\u0432\u0435\u0442\u043e\u0432 <code>UIColorPickerViewController<\/code> \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e. <\/p>\n<p>\u0414\u043b\u044f \u0433\u0430\u043b\u0435\u0440\u0435\u0438 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e\u0441\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0441 \u043f\u043b\u0430\u0432\u043d\u043e\u0439 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0435\u0439 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e pinchgesture \u0432 \u0441\u0442\u0438\u043b\u0435 \u044d\u043f\u043b\u043e\u0432\u0441\u043a\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f Photos.<\/p>\n<p>\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0438 \u043d\u0435\u043c\u0430\u043b\u043e\u0432\u0430\u0436\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u0441\u0442\u0430 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u043b\u0430\u0441\u044c \u0432 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0438 \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0438\u0437 \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u044b\u0445 \u043c\u0430\u043a\u0435\u0442\u043e\u0432 \u0442\u0430\u043a \u0438\u043b\u0438 \u0438\u043d\u0430\u0447\u0435 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0431\u044b \u043e\u0442\u043b\u043e\u0436\u0438\u0442\u044c \u043d\u0430 \u0431\u0443\u0434\u0443\u0449\u0435\u0435.<\/p>\n<p>\u0421\u0430\u043c\u044b\u043c \u0432\u0430\u0436\u043d\u044b\u043c (\u0438 \u043a\u0440\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043a\u0430\u043a \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u0437\u0436\u0435) \u0441\u0442\u0430\u043b\u0430 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0430 \u043b\u0438\u043d\u0438\u0438, \u0430 \u0432\u0441\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0442\u0438\u043f\u0430 \u043a\u0430\u0440\u0430\u043d\u0434\u0430\u0448\u0430, \u043c\u0430\u0440\u043a\u0435\u0440\u0430 \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435 \u0438\u043c\u0435\u043b\u0438 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043c\u0435\u043d\u044c\u0448\u0438\u0439 \u0438\u043c\u043f\u0430\u043a\u0442 \u043d\u0430 \u0438\u0442\u043e\u0433\u043e\u0432\u0443\u044e \u043e\u0446\u0435\u043d\u043a\u0443.<\/p>\n<p>\u0412 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u0445 \u043a\u043e\u043d\u043a\u0443\u0440\u0441 \u0431\u044b\u043b\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u0438 \u043f\u0440\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u043d\u0430\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u043d\u0430 \u0432\u0438\u0434\u0435\u043e \u0432 \u0433\u0430\u043b\u0435\u0440\u0435\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u043d\u043e \u043e\u0431 \u044d\u0442\u043e\u043c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0437\u0436\u0435.<\/p>\n<p>\u041a\u0440\u043e\u043c\u0435 \u044d\u0442\u043e\u0433\u043e, \u0432\u0430\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 \u043a \u0432\u0438\u0434\u0443, \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u043c\u0443 \u043d\u0430 <a href=\"https:\/\/t.me\/contest\/304\" rel=\"noopener noreferrer nofollow\">\u0432\u0438\u0434\u0435\u043e<\/a>.<\/p>\n<h2>\u0413\u0430\u043b\u0435\u0440\u0435\u044f (\u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0444\u043e\u0442\u043e \u0438 \u0432\u0438\u0434\u0435\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f)<\/h2>\n<p>\u0422\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0435 \u2014 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440, \u0435\u0441\u043b\u0438 \u043d\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u0430, \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u044b \u043c\u0435\u0436\u0434\u0443 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u0442\u0438\u043f\u0430 \u043b\u044d\u0439\u0430\u0443\u0442\u0430 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0436\u0435\u0441\u0442\u043e\u0432.<\/p>\n<p>\u0414\u043b\u044f \u044d\u043a\u0440\u0430\u043d\u0430 \u0441 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u043e \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 Lotti\u0435 (\u0438\u043b\u0438 rlottie \u2014 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0435\u0433\u043e, \u0442\u0430\u043a \u043a\u0430\u043a \u0432 \u0441\u0432\u043e\u0438\u0445 \u0440\u0430\u0431\u043e\u0447\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u0434\u043b\u044f \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0435\u0439 \u043e\u043d \u0432\u044b\u0438\u0433\u0440\u044b\u0432\u0430\u0435\u0442 \u043f\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438).<\/p>\n<p>\u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 \u0441\u0432\u0430\u0439\u043f\u043e\u0432 \u043e\u043f\u0438\u0440\u0430\u043b\u0441\u044f \u043d\u0430 <code>UIPinchGestureRecognizer<\/code> \u0438 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u043c\u0430\u0441\u0448\u0442\u0430\u0431. <\/p>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u043c \u0442\u0435\u043a\u0443\u0449\u0443\u044e \u044f\u0447\u0435\u0439\u043a\u0443, \u0430 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0441\u0432\u0430\u0439\u043f\u0430 \u043f\u0435\u0440\u0435\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c \u043b\u044d\u0439\u0430\u0443\u0442 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u0430 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<pre><code class=\"swift\">let potentialScale:CGFloat = min(maxScale, max(scaleStart * pinchReco.scale, minScale)) let scaleToRound: Double = potentialScale let scale = scaleToRound.round(nearest: 0.05) if scale != currentScale {     currentScale = scale     \u0441vGallery.collectionViewLayout.invalidateLayout()     guard let path = pathToScroll else {         return     }     cvGallery.scrollToItem(at: path, at: .centeredVertically, animated: false) }<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 \u043a\u043e\u043d\u043a\u0443\u0440\u0441\u0430\u043d\u0442\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 <strong>\u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0439 \u0440\u0430\u0441\u0447\u0451\u0442<\/strong>,<strong> <\/strong>\u043d\u043e \u0442\u0430\u043a \u043a\u0430\u043a \u0434\u043b\u044f \u0441\u0435\u0431\u044f \u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043b\u0438\u043b \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442 \u043d\u0430 \u043c\u0435\u0434\u0438\u0430\u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440, \u0442\u043e \u043d\u0430 \u044d\u0442\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u0432 \u0433\u0430\u043b\u0435\u0440\u0435\u0435 \u044f \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0441\u044f.<\/p>\n<p>\u0421\u0430\u043c\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043a \u0433\u0430\u043b\u0435\u0440\u0435\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u0447\u0435\u0440\u0435\u0437 <code>fetchAssetCollections<\/code>, \u0430 \u043c\u0435\u0434\u0438\u0430\u0444\u0430\u0439\u043b\u044b \u043a\u044d\u0448\u0438\u043b\u0438\u0441\u044c \u0447\u0435\u0440\u0435\u0437 <code>PHImageManager<\/code>. \u0412 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043b\u044d\u0439\u0430\u0443\u0442\u0430 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u043b\u0441\u044f \u0440\u0430\u0437\u043c\u0435\u0440 \u0434\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u043f\u043b\u0430\u0432\u043d\u043e\u0433\u043e \u0441\u043a\u0440\u043e\u043b\u043b\u0430 \u0438 \u0432 \u0446\u0435\u043b\u043e\u043c \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>\u041a\u0440\u043e\u043c\u0435 \u044d\u0442\u043e\u0433\u043e, \u0434\u043b\u044f \u043a\u0435\u0439\u0441\u043e\u0432 \u0441 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438 \u044f\u0447\u0435\u0439\u043a\u0430\u043c\u0438 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e\u0441\u044c \u0441\u043a\u0440\u044b\u0432\u0430\u043b\u0430\u0441\u044c \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0430\u0441\u0441\u0435\u0442\u043e\u0432.<\/p>\n<h2>\u041c\u0435\u0434\u0438\u0430\u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440<\/h2>\n<p>\u0412 \u044d\u0442\u043e\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0435 \u043f\u043e\u0439\u0434\u0451\u0442 \u0440\u0435\u0447\u044c \u043e \u043f\u0440\u0438\u043d\u044f\u0442\u044b\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u044f\u0445, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441 \u0432\u044b\u0431\u043e\u0440\u043e\u043c \u0446\u0432\u0435\u0442\u0430, \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u043e\u0439 \u043b\u0438\u043d\u0438\u0438, \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u043c \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0435 \u0438 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0438 \u0432\u0441\u0435\u0433\u043e \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0433\u043e.<\/p>\n<h4>\u0412\u044b\u0431\u043e\u0440 \u0446\u0432\u0435\u0442\u0430<\/h4>\n<p>\u0411\u044b\u043b\u043e \u043f\u0440\u0438\u043d\u044f\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0432\u0441\u0451 \u0441 \u043d\u0443\u043b\u044f, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0445\u043e\u043b\u0441\u0442\u043e\u043c, \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c \u0438 \u0441\u043b\u043e\u044f\u043c\u0438,  \u0442\u0430\u043a\u0436\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0434\u043b\u044f \u0432\u044b\u0431\u043e\u0440\u0430 \u0446\u0432\u0435\u0442\u0430:<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0432\u044b\u0431\u043e\u0440\u0430 \u0446\u0432\u0435\u0442\u0430 \u0432 \u043c\u043e\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438?<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/2ac\/586\/2b0\/2ac5862b0d63d28f43fa8025627ab072.jpg\" width=\"2400\" height=\"1600\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2ac\/586\/2b0\/2ac5862b0d63d28f43fa8025627ab072.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0414\u043b\u044f \u043f\u043e\u0432\u0442\u043e\u0440\u0435\u043d\u0438\u044f \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0440\u0438 \u0440\u0430\u0437\u0434\u0435\u043b\u0430: grid, spectrum \u0438 sliders.<\/p>\n<\/div>\n<\/details>\n<h4>\u042d\u043a\u0440\u0430\u043d \u0441 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u0442\u0438\u043f\u043e\u0432 \u0432\u044b\u0431\u043e\u0440\u0430 \u0446\u0432\u0435\u0442\u0430<\/h4>\n<p>\u042f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b \u0435\u0433\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>UIStackView + UIPageViewController.<\/code> \u0412 \u0441\u0442\u044d\u043a\u0432\u044c\u044e \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f, \u0441\u043f\u0435\u043a\u0442\u0440 (\u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 \u0438 \u0436\u0435\u0441\u0442\u0430 \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u0437\u0438\u0446\u0438\u0438) \u0438\u043b\u0438 \u0436\u0435 \u043d\u0430\u0431\u043e\u0440 \u0441\u043b\u0430\u0439\u0434\u0435\u0440\u043e\u0432 \u0441 \u043f\u043e\u043b\u044f\u043c\u0438 \u0432\u0432\u043e\u0434\u0430.<\/p>\n<p>\u0414\u043b\u044f \u0441\u043b\u0430\u0439\u0434\u0435\u0440\u0430 \u0438 \u0448\u0430\u0445\u043c\u0430\u0442\u043a\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b:<\/p>\n<details class=\"spoiler\">\n<summary>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0448\u0430\u0445\u043c\u0430\u0442\u043a\u0438 \u0432 \u0441\u043b\u0430\u0439\u0434\u0435\u0440\u0435<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"swift\">private func renderCheckerboardPattern(colors: (dark: UIColor, light: UIColor), height:CGFloat) -> UIColor {     let size = height\/3     let image = UIGraphicsImageRenderer(size: CGSize(width: size * 2, height: size * 2)).image { context in         colors.dark.setFill()         context.fill(CGRect(x: 0, y: 0, width: size * 2, height: size * 2))         colors.light.setFill()         context.fill(CGRect(x: size, y: 0, width: size, height: size))         context.fill(CGRect(x: 0, y: size, width: size, height: size))     }     return UIColor(patternImage: image) }<\/code><\/pre>\n<p>\u0412\u044b\u0441\u043e\u0442\u0430 \u0434\u0435\u043b\u0438\u0442\u0441\u044f \u043d\u0430 3, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0443\u0436\u043d\u043e \u0442\u0440\u0438 \u0440\u044f\u0434\u0430. \u0421\u0430\u043c\u0443 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443 \u0433\u0435\u043d\u0435\u0440\u0438\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>UIGraphicsImageRenderer.<\/code><\/p>\n<\/div>\n<\/details>\n<p>\u041a\u0430\u043a \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442\u0441\u044f \u0446\u0432\u0435\u0442\u0430 \u0441\u043b\u0435\u0432\u0430 \u0438 \u0441\u043f\u0440\u0430\u0432\u0430 \u043d\u0430 \u0441\u043b\u0430\u0439\u0434\u0435\u0440\u0430\u0445, \u0434\u043e \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u043d\u043a\u0443\u0440\u0441\u0430 \u043d\u0435 \u0437\u043d\u0430\u043b, \u043d\u043e \u0440\u0430\u0434\u0438 \u044d\u0442\u043e\u0433\u043e \u0438 \u0441\u0442\u043e\u0438\u0442 \u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c, \u0440\u0430\u0437\u0432\u0435 \u043d\u0435\u0442? \u0412 \u0438\u0442\u043e\u0433\u0435 \u0431\u044b\u043b\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0445 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u043e\u0432 \u0441\u043b\u0430\u0439\u0434\u0435\u0440\u0430:<\/p>\n<pre><code class=\"swift\">var rgba: (red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat) {     var red: CGFloat = 0     var green: CGFloat = 0     var blue: CGFloat = 0     var alpha: CGFloat = 0     getRed(&amp;red, green: &amp;green, blue: &amp;blue, alpha: &amp;alpha)          return (red, green, blue, alpha) }  func max(red:Bool = false, green:Bool = false, blue:Bool = false) -> UIColor {     let rgba = self.rgba     return UIColor(red: red ? 1 : rgba.red, green: green ? 1 : rgba.green, blue: blue ? 1 : rgba.blue, alpha: rgba.alpha) }  func min(red:Bool = false, green:Bool = false, blue:Bool = false) -> UIColor {     let rgba = self.rgba     return UIColor(red: red ? 0 : rgba.red, green: green ? 0 : rgba.green, blue: blue ? 0 : rgba.blue, alpha: rgba.alpha) }  static func colorFrom(rgba: (red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat)) -> UIColor {     return UIColor(red: rgba.red, green: rgba.green, blue: rgba.blue, alpha: rgba.alpha) }<\/code><\/pre>\n<p>\u041d\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u044e, \u0447\u0442\u043e \u0435\u0441\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0449\u0435, \u043d\u043e \u044f \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u043b, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043c\u044b \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u043c \u0446\u0432\u0435\u0442\u043e\u043c, \u0442\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0435\u043c\u0443 0 \u0438 1 \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0446\u0432\u0435\u0442\u0430 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043d\u0443\u0436\u043d\u043e\u0433\u043e.<\/p>\n<p>\u0414\u043b\u044f \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u043d\u0443\u0436\u043d\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f <code>UITextField<\/code> (\u0430 \u0447\u0442\u043e \u0436\u0435 \u0435\u0449\u0451).<\/p>\n<h4>\u0421\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0446\u0432\u0435\u0442\u0430\u043c\u0438<\/h4>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c UIPageViewController \u0441 \u0440\u0430\u0441\u0447\u0451\u0442\u043e\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0446\u0432\u0435\u0442\u043e\u0432 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443. <\/p>\n<pre><code class=\"swift\">func chunked(into size: Int) -> [[Element]] {     return stride(from: 0, to: count, by: size).map {         Array(self[$0 ..&lt; Swift.min($0 + size, count)])     } }<\/code><\/pre>\n<p>\u041f\u0440\u0438 \u0432\u044b\u0445\u043e\u0434\u0435 \u0441 \u044d\u043a\u0440\u0430\u043d\u0430 \u043c\u0430\u0441\u0441\u0438\u0432 \u0446\u0432\u0435\u0442\u043e\u0432 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u0432 <code>UserDefaults<\/code> \u0432 \u0432\u0438\u0434\u0435 <strong>hex-\u0441\u0442\u0440\u043e\u043a\u0438<\/strong>. \u0418\u0437 \u043d\u0435\u0451 \u0436\u0435 \u0438 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0435 \u0446\u0432\u0435\u0442\u0430 \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c.<\/p>\n<h4>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0438\u043f\u0435\u0442\u043a\u0438 (\u043e\u043d\u043e \u0436\u0435 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0441\u0442\u0435\u043a\u043b\u043e, \u0438\u043b\u0438 \u0436\u0435 \u043b\u0443\u043f\u0430)<\/h4>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b \u0441\u0432\u044f\u0437\u043a\u0443 \u0438\u0437 \u0436\u0435\u0441\u0442\u0430 \u0438 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u043c\u0430\u0433\u043d\u0438\u0444\u0430\u0439-\u044d\u0444\u0444\u0435\u043a\u0442\u0430 \u0432 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0435.<\/p>\n<pre><code class=\"swift\">public override func draw(_ rect: CGRect) {     guard let context = UIGraphicsGetCurrentContext() else { return }      context.translateBy(x: radius, y: radius)     context.scaleBy(x: scale, y: scale)     context.translateBy(x: -magnifiedPoint.x, y: -magnifiedPoint.y)     context.interpolationQuality = .none     removeFromSuperview()     magnifiedView?.layer.render(in: context)     magnifiedView?.superview?.addSubview(self) }<\/code><\/pre>\n<p>\u0410\u0445 \u0434\u0430, \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043d\u0435\u043e\u0431\u044b\u0447\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043e\u0442 \u0434\u0438\u0437\u0430\u0439\u043d\u0435\u0440\u043e\u0432 Telegram \u043e\u0442 \u0447\u0451\u0440\u043d\u043e\u0433\u043e \u043a \u043d\u0443\u0436\u043d\u043e\u043c\u0443. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0431\u044b\u043b\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>CIFilter<\/code>:<\/p>\n<pre><code class=\"swift\">  static func filteredImage(cgImage: CGImage, size:CGSize) -> UIImage? {       if let matrixFilter = CIFilter(name: \"CIColorMatrix\") {           matrixFilter.setDefaults()           matrixFilter.setValue(CIImage(cgImage: cgImage), forKey: kCIInputImageKey)           let rgbVector = CIVector(x: 0, y: 0, z: 0, w: 0)           let aVector = CIVector(x: 1, y: 1, z: 1, w: 0)           matrixFilter.setValue(rgbVector, forKey: \"inputRVector\")           matrixFilter.setValue(rgbVector, forKey: \"inputGVector\")           matrixFilter.setValue(rgbVector, forKey: \"inputBVector\")           matrixFilter.setValue(aVector, forKey: \"inputAVector\")           matrixFilter.setValue(CIVector(x: 1, y: 1, z: 1, w: 0), forKey: \"inputBiasVector\")            if let matrixOutput = matrixFilter.outputImage, let cgImage = CIContext().createCGImage(matrixOutput, from: matrixOutput.extent) {               return UIImage(cgImage: cgImage).resizedImage(with: size)           }        }       return nil   }<\/code><\/pre>\n<p>\u0422\u043e \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c, \u043f\u043e\u0434 \u0441\u043f\u043e\u0439\u043b\u0435\u0440\u043e\u043c \u043d\u0438\u0436\u0435.<\/p>\n<details class=\"spoiler\">\n<summary>\u0410 \u0432\u043e\u0442 \u0442\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u044d\u0442\u043e\u0442 \u044d\u0444\u0444\u0435\u043a\u0442 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/953\/600\/bbc\/953600bbcfa41f725d2db79408f0ff60.jpg\" width=\"2400\" height=\"1600\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/953\/600\/bbc\/953600bbcfa41f725d2db79408f0ff60.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<h4>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u0434\u043b\u044f \u0432\u044b\u0431\u043e\u0440\u0430 \u0446\u0432\u0435\u0442 \u0441 \u044d\u043a\u0440\u0430\u043d\u0430 \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u044f<\/h4>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u0434\u0435\u043b\u0430\u043b \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b \u0441 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439 \u0434\u0432\u0443\u0445 \u0436\u0435\u0441\u0442\u043e\u0432 (\u0434\u043b\u044f \u0434\u043b\u0438\u043d\u043d\u043e\u0433\u043e \u043a\u0430\u0441\u0430\u043d\u0438\u044f \u0438 \u043a\u043e\u0440\u043e\u0442\u043a\u043e\u0433\u043e \u2014 \u0434\u043b\u044f \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f \u043f\u0438\u043a\u0435\u0440\u0430).<\/p>\n<pre><code class=\"swift\">  func addShortAndLongTaps(needShort:Bool = false, needLong:Bool = false) {       if needShort {           let tapGesture = UITapGestureRecognizer(target: self, action: #selector(onShort))           addGestureRecognizer(tapGesture)       }        if needLong {           let longGesture = UILongPressGestureRecognizer(target: self, action: #selector(onLong))           longGesture.minimumPressDuration = 0.3           addGestureRecognizer(longGesture)       }   }<\/code><\/pre>\n<h2>\u0410\u043d\u0438\u043c\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a\u0430\u0440\u0430\u043d\u0434\u0430\u0448\u0435\u0439 (\u0438 \u0438\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f)<\/h2>\n<details class=\"spoiler\">\n<summary>\u0427\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c<\/summary>\n<div class=\"spoiler__content\">\n<div class=\"tm-iframe_temp\" data-src=\"https:\/\/embedd.srv.habr.com\/iframe\/636e02766dab065090ebff98\" data-style=\"\" id=\"636e02766dab065090ebff98\" width=\"\"><\/div>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0411\u0430\u0437\u0430 \u2014 \u044d\u0442\u043e <code>UICollectionView<\/code> \u0441 \u044f\u0447\u0435\u0439\u043a\u0430\u043c\u0438 \u043d\u0430 \u0430\u0432\u0442\u043e\u043b\u044d\u0439\u0430\u0443\u0442\u0435. \u0421\u0430\u043c\u0430 \u044f\u0447\u0435\u0439\u043a\u0430 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0444\u043e\u043d\u0430 \u0434\u043b\u044f \u043a\u0430\u0440\u0430\u043d\u0434\u0430\u0448\u0430, \u043e\u0432\u0435\u0440\u043b\u044d\u044f (\u0433\u0440\u0438\u0444\u0435\u043b\u044c) \u0438 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u0434\u043b\u044f \u0442\u043e\u0449\u0438\u043d\u044b \u043a\u0430\u0440\u0430\u043d\u0434\u0430\u0448\u0430.<\/p>\n<p>\u0414\u043b\u044f \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 \u0440\u0435\u0448\u0438\u043b \u0441\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u044f\u0447\u0435\u0439\u043a\u0438 \u0447\u0435\u0440\u0435\u0437 \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u0435 \u0432\u044b\u0441\u043e\u0442\u044b \u043a\u0430\u0440\u0430\u043d\u0434\u0430\u0448\u0435\u0439 \u0441 \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u043e\u0439 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0438\u0445 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u0432 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0441 \u0432\u044b\u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0435\u043c \u043d\u0443\u0436\u043d\u043e\u0433\u043e \u043d\u0430 \u043f\u043e\u0437\u0438\u0446\u0438\u044e \u043f\u043e\u0441\u0435\u0440\u0435\u0434\u0438\u043d\u0435 (\u0447\u0435\u0440\u0435\u0437 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043f\u043e\u0437\u0438\u0446\u0438\u0439 \u044f\u0447\u0435\u0435\u043a). \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0442\u0430\u043a\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u043b\u0430\u0432\u043d\u043e\u0435 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435 \u0442\u043e\u043b\u0449\u0438\u043d\u044b \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u0430.<\/p>\n<p>\u0414\u043b\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u043b\u0430\u0441\u0442\u0438\u043a\u0430 \u0442\u0430\u043a\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 (\u0431\u043b\u044e\u0440 \u0438\u043b\u0438 \u0441\u0442\u0438\u0440\u0430\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432).<\/p>\n<p>\u041f\u0440\u0438 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u043c\u0435\u0436\u0434\u0443 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u043c\u0438 \u0440\u0435\u0436\u0438\u043c\u0430\u043c\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u044f \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c-\u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 \u0441\u043b\u0430\u0439\u0434\u0435\u0440\u0430. \u0415\u0449\u0451 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u043e\u043a\u0430\u0437 \u0438 \u0441\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u0435 \u0441\u043b\u0430\u0439\u0434\u0435\u0440\u0430 \u0432 \u043e\u0434\u043d\u0443 \u0442\u043e\u0447\u043a\u0443 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435, \u043d\u043e \u044f \u043f\u043e\u043c\u043d\u0438\u043b \u043e\u0431 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f\u0445 \u043a\u043e\u043d\u043a\u0443\u0440\u0441\u0430 \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438.<\/p>\n<details class=\"spoiler\">\n<summary>\u041d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u043c\u0430\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0447\u0438\u0441\u043b\u0430 \u0432 \u043f\u0440\u043e\u0434\u0435!<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"swift\">let delay:Double = Double(tool.type.rawValue) * 0.05 var constantBottom:CGFloat = -16 if tool.current {     constantBottom = CGFloat.leastNormalMagnitude } bottomTool.constant = constantBottom heightColor.constant = tool.width topOffsetIconEraser.constant = 20 widthToolConstraint.constant = defaultWidthTool topOffsetColor.constant = topOffsetForTool(tool: tool) centerToolContraint.constant = CGFloat.leastNormalMagnitude<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<h2>\u0422\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0439 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440<\/h2>\n<p>\u041a\u0430\u043a \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u0441\u044f, \u0443\u0434\u0435\u043b\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043c\u0435\u043b\u043e\u0447\u0430\u043c (\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043a\u043e\u043d\u0446\u0435). \u041e\u0434\u043d\u0430 \u0438\u0437 \u043c\u043e\u0438\u0445 \u043e\u0448\u0438\u0431\u043e\u043a \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u043d\u0438\u044f, \u0447\u0442\u043e \u0438\u043d\u043e\u0433\u0434\u0430 \u0442\u0430\u043a \u0438\u043b\u0438 \u0438\u043d\u0430\u0447\u0435 \u0437\u0430\u0446\u0438\u043a\u043b\u0438\u0432\u0430\u043b\u0441\u044f \u043d\u0430 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u043c\u043e\u043c\u0435\u043d\u0442\u0430\u0445. <\/p>\n<p>\u041a\u0430\u043a \u0431\u044b \u0432\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b\u0438 \u044d\u0444\u0444\u0435\u043a\u0442 \u0441\u043a\u0440\u044b\u0442\u0438\u044f \u043b\u0435\u0432\u043e\u0439 \u0438 \u043f\u0440\u0430\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 \u043f\u0440\u0438 \u0441\u043a\u0440\u043e\u043b\u043b\u0435?<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/98e\/f44\/564\/98ef44564bdb9a0b698f8ba544c4f894.jpeg\" width=\"1179\" height=\"508\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/98e\/f44\/564\/98ef44564bdb9a0b698f8ba544c4f894.jpeg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<details class=\"spoiler\">\n<summary>\u0427\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043b \u044f<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"swift\">let transparent = UIColor.clear let opaque = UIColor.black  let gradient = CAGradientLayer() gradient.frame = bounds gradient.colors = [     transparent.cgColor,     opaque.cgColor,     opaque.cgColor,     opaque.withAlphaComponent(0).cgColor ] gradient.locations = [0, 0.2, 0.8, 1] gradient.startPoint = CGPoint(x: 0, y: 0.5) gradient.endPoint = CGPoint(x: 1, y: 0.5) gradient.name = GRADIENT_HARD layer.mask = needMask ? gradient : nil<\/code><\/pre>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442 \u0441 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043b\u043e\u043a\u0430\u0446\u0438\u044f\u043c\u0438 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043c\u0430\u0441\u043a\u0438. <code>needMask<\/code> \u043d\u0443\u0436\u0435\u043d \u0434\u043b\u044f \u0440\u0435\u0436\u0438\u043c\u0430, \u043a\u043e\u0433\u0434\u0430 \u0443 \u043d\u0430\u0441 \u0432\u0438\u0434\u043d\u0430 \u043a\u043b\u0430\u0432\u0438\u0430\u0442\u0443\u0440\u0430 (\u0438 \u043f\u043e \u043c\u0430\u043a\u0435\u0442\u0443 \u0442\u0430\u043c \u044d\u0442\u043e\u0433\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0430 \u0431\u044b\u0442\u044c \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u043e).<\/p>\n<\/div>\n<\/details>\n<h2>\u041a\u0430\u043a\u0438\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u044b \u0434\u043b\u044f \u0442\u0435\u043a\u0441\u0442\u0430 \u0431\u044b\u043b\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b<\/h2>\n<p>\u0417\u0430\u043b\u0438\u0432\u043a\u0430 \u0446\u0432\u0435\u0442\u043e\u043c, \u0442\u0435\u043d\u044c \u0443 \u0431\u0443\u043a\u0432, \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0442\u0435\u043a\u0441\u0442\u0430, \u043f\u043e\u043b\u0443\u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u0430\u044f \u0437\u0430\u043b\u0438\u0432\u043a\u0430 (\u0434\u0430, \u0442\u0443\u0442 \u0435\u0441\u0442\u044c \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u0441 \u043e\u0431\u044b\u0447\u043d\u043e\u0439). \u0414\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u043b\u043e\u0451\u0432, \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0438\u0445 \u043f\u043e \u0441\u0442\u0435\u043a\u0443, \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435. \u0410 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u0432\u0441\u0435\u0445 \u044d\u0442\u0438\u0445 \u044d\u0444\u0444\u0435\u043a\u0442\u043e\u0432 \u043f\u0440\u0438 \u0432\u044b\u0431\u043e\u0440\u0435 \u0441\u043b\u043e\u044f.<\/p>\n<details class=\"spoiler\">\n<summary>\u0421\u043a\u0440\u0438\u043d\u0448\u043e\u0442 \u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/b0a\/a60\/896\/b0aa608968a5ece7b0fb3e2ca76a0ad0.jpg\" width=\"2400\" height=\"1600\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b0a\/a60\/896\/b0aa608968a5ece7b0fb3e2ca76a0ad0.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0443 \u0442\u0435\u043a\u0441\u0442\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e CATextLayer \u0438 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0438 \u043d\u0443\u0436\u043d\u044b\u0445 \u044d\u0444\u0444\u0435\u043a\u0442\u043e\u0432.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0442\u0435\u043d\u044c \u0443 \u0431\u0443\u043a\u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c:<\/p>\n<pre><code class=\"swift\">context.setTextDrawingMode(CGTextDrawingMode.stroke) context.setLineWidth(0.25*fontSize) context.setLineJoin(CGLineJoin.round) context.setLineCap(CGLineCap.butt) context.setStrokeColor(UIColor.black.cgColor) var attrsFill = attributes attrsFill[.foregroundColor] = UIColor.black (self.text as NSString).draw(in: drawRect, withAttributes: attrsFill)  context.setTextDrawingMode(.fill) context.setFillColor(UIColor.clear.cgColor) let attrsStroke = attributes let drawRect = CGRect(x: 0.5, y: 0, width: bounds.width + 1, height: bounds.height) (self.text as NSString).draw(in: drawRect, withAttributes: attrsStroke)<\/code><\/pre>\n<p>\u0410 \u0432\u043e\u0442 \u0437\u0430\u043b\u0438\u0432\u043a\u0430 \u043a\u0443\u0434\u0430 \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u0430\u044f. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0431\u044b\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d NSLayoutManager, \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u044f\u043c\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u043e\u0432 \u0441 \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u043e\u043c \u0434\u043b\u044f \u0442\u0435\u043a\u0441\u0442\u0430 \u0438 \u043f\u0440\u043e\u0445\u043e\u0434 \u043f\u043e \u043d\u0438\u043c \u0434\u043b\u044f \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u043d\u0443\u0436\u043d\u044b\u0445 \u0441\u043a\u0440\u0443\u0433\u043b\u0451\u043d\u043d\u044b\u0445 \u0433\u0440\u0430\u043d\u0438\u0446. \u041c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u043e\u0449\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u0437\u0430\u043b\u0438\u0432\u043a\u0438 \u0430\u0442\u0440\u0438\u0431\u0443\u0442-\u0441\u0442\u0440\u043e\u043a\u0438, \u043d\u043e \u044d\u0442\u043e \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435 \u0442\u043e. \u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043d\u0438\u0436\u0435 \u0447\u0430\u0441\u0442 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0443\u0442\u0438 \u0434\u043b\u044f \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438.<\/p>\n<pre><code class=\"swift\">  if a.x - c.x >= 2*R {       let addPath = UIBezierPath(arcCenter: CGPointMake(a.x - R, a.y + R), radius:R, startAngle:Double.pi\/2 * 3, endAngle:0, clockwise:true)       addPath.append(UIBezierPath(arcCenter: CGPointMake(a.x + R, a.y + R) , radius:R, startAngle:Double.pi, endAngle:3 * Double.pi\/2, clockwise:true))       addPath.addLine(to: CGPointMake(a.x - R, a.y))       path.append(addPath)   }      if a.x == c.x {       path.move(to: CGPointMake(a.x, a.y - R))       path.addLine(to: CGPointMake(a.x, a.y + R))       path.addArc(withCenter: CGPointMake(a.x + R, a.y + R), radius: R, startAngle: Double.pi, endAngle: Double.pi\/2 * 3, clockwise: true)       path.addArc(withCenter: CGPointMake(a.x + R, a.y - R), radius: R, startAngle: Double.pi\/2, endAngle: Double.pi, clockwise: true)   }<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0433\u0440\u0430\u043d\u0438\u0446 \u0443 \u0441\u043b\u043e\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u043e\u043a\u0430\u043d\u0442\u043e\u0432\u043a\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>UIBezierPath<\/code>.<\/p>\n<p>\u0414\u043b\u044f \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u043b\u043e\u0451\u0432 \u043f\u0430\u0440\u0430\u0434\u043e\u043a\u0441\u0430\u043b\u044c\u043d\u043e \u043d\u0435\u043b\u044c\u0437\u044f \u0441\u0434\u0435\u043b\u0430\u0442\u044c <code>copy<\/code>. \u0415\u0441\u043b\u0438 \u043c\u043e\u0436\u043d\u043e, \u043d\u0430\u043f\u0438\u0448\u0438\u0442\u0435 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445. \u042f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>NSKeyedArchiver\/NSKeyedUnarchiver<\/code> \u0438 \u043f\u0435\u0440\u0435\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043d\u0443\u0436\u043d\u044b\u0445 \u0441\u0432\u043e\u0439\u0441\u0442\u0432.<\/p>\n<p>\u0414\u043b\u044f \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0446\u0435\u043b\u044b\u0445 \u0442\u0440\u0438 \u0436\u0435\u0441\u0442\u0430 &#8212; \u0434\u043b\u044f \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u0430 \u0447\u0435\u0440\u0435\u0437 <code>UIRotationGestureRecognizer<\/code>, \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u0447\u0435\u0440\u0435\u0437 Pan \u0438 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f <code>UIPinchGestureRecognizer<\/code>. <\/p>\n<p>\u0418 \u0442\u0443\u0442 \u043d\u0430\u0447\u0430\u043b\u0438\u0441\u044c \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0441 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439 \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0438 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u044f. \u041f\u0430\u0440\u0430\u0434\u043e\u043a\u0441\u0430\u043b\u044c\u043d\u043e, \u043d\u043e \u043f\u043e\u043c\u043e\u0433\u043b\u0430 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044f \u0436\u0435\u0441\u0442\u043e\u0432 \u0447\u0435\u0440\u0435\u0437 <code>gestureRecognizerShouldBegin<\/code> \u0438 <code>shouldRecognizeSimultaneouslyWith.<\/code><\/p>\n<p>\u041d\u0435 \u0437\u043d\u0430\u044e, \u043a\u0430\u043a \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u043b\u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u0438 \u043a \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0438 \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u043e\u0432 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0445 \u0441\u043b\u043e\u0451\u0432, \u043d\u043e \u0437\u0430\u0434\u0430\u0447\u0430 \u043b\u044e\u0431\u043e\u043f\u044b\u0442\u043d\u0430\u044f.<\/p>\n<h2>\u041e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0430 \u043b\u0438\u043d\u0438\u0439 \u0438\u043b\u0438 \u0442\u043e, \u043a \u0447\u0435\u043c\u0443 \u044f \u043f\u0440\u0438\u0448\u0451\u043b \u0432 \u0438\u0442\u043e\u0433\u0435<\/h2>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u0431\u044b\u043b\u043e \u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>PencilKit<\/code>, \u043d\u043e \u044f \u043f\u043e\u0448\u0451\u043b \u043f\u043e \u0434\u0440\u0443\u0433\u043e\u043c\u0443 \u043f\u0443\u0442\u0438.<\/p>\n<p>\u0414\u043b\u044f \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u043b\u0438\u043d\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434, \u0442\u0440\u0435\u0431\u0443\u044e\u0449\u0438\u0439 \u0432\u044b\u0445\u043e\u0434\u0430 \u0438\u0437 \u043f\u043b\u043e\u0441\u043a\u043e\u0441\u0442\u0438. \u0412\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u0430\u0440\u0438\u0441\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0448\u0442\u0440\u0438\u0445 \u043e\u0434\u043d\u043e\u0439 \u043a\u0440\u0438\u0432\u043e\u0439 \u0411\u0435\u0437\u044c\u0435, \u044f \u0435\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u043b \u043a\u0430\u043a \u0437\u0430\u043a\u0440\u0430\u0448\u0435\u043d\u043d\u0443\u044e \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u043f\u0443\u0442\u044f\u043c\u0438 \u0411\u0435\u0437\u044c\u0435, \u043a\u0430\u0436\u0434\u044b\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043f\u0443\u0442\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0441\u043b\u0435\u0433\u043a\u0430 \u0441\u043c\u0435\u0449\u0435\u0430 \u043f\u043e \u043e\u0431\u0435 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u043e\u0442 \u0432\u043e\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c\u043e\u0439 \u043a\u0440\u0438\u0432\u043e\u0439, \u043e\u0447\u0435\u0440\u0447\u0435\u043d\u043d\u043e\u0439 \u043f\u0430\u043b\u044c\u0446\u0435\u043c.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u044b\u0445 \u0442\u043e\u0447\u0435\u043a, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0449\u0438\u0445 \u044d\u0442\u0438 \u0434\u0432\u0435 \u043a\u0440\u0438\u0432\u044b\u0435 \u0411\u0435\u0437\u044c\u0435, \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u0430\u0432\u0434\u043e\u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0433\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0430 \u043f\u043b\u0430\u0432\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u044f\u044e\u0449\u0435\u0439\u0441\u044f \u0448\u0438\u0440\u0438\u043d\u044b \u043f\u0435\u0440\u0430.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/eaa\/265\/53e\/eaa26553e3d9e3f7a3080cd8fa7c87da.png\" alt=\"\u0422\u043e, \u0447\u0442\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0441\u0434\u0435\u043b\u0430\u0442\u044c\" title=\"\u0422\u043e, \u0447\u0442\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0441\u0434\u0435\u043b\u0430\u0442\u044c\" width=\"652\" height=\"397\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/eaa\/265\/53e\/eaa26553e3d9e3f7a3080cd8fa7c87da.png\"\/><figcaption>\u0422\u043e, \u0447\u0442\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0441\u0434\u0435\u043b\u0430\u0442\u044c<\/figcaption><\/figure>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/f6c\/04d\/cce\/f6c04dcce4c7ac6add104a9c8d27ae1c.png\" alt=\"\u0418 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f\" title=\"\u0418 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f\" width=\"360\" height=\"307\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f6c\/04d\/cce\/f6c04dcce4c7ac6add104a9c8d27ae1c.png\"\/><figcaption>\u0418 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f<\/figcaption><\/figure>\n<p>\u041f\u043e\u0442\u0440\u044f\u0441\u0430\u044e\u0449\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043d\u0430 \u044d\u0442\u0443 \u0442\u0435\u043c\u0443 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0430 <a href=\"https:\/\/code.tutsplus.com\/tutorials\/ios-sdk-advanced-freehand-drawing-techniques--mobile-15602\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>. \u0414\u0430, \u043f\u043e \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f\u043c \u043d\u0443\u0436\u0435\u043d Swift, \u0430 \u043d\u0435 Objective-C, \u043d\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043d\u0435\u0442.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/214\/b67\/9c1\/214b679c1ae686fcebc8c5647ea71b6e.jpeg\" alt=\"\u041f\u0440\u0438\u043c\u0435\u0440 \u0442\u0435\u043a\u0441\u0442\u0430 \u0438\u0437 \u0441\u0442\u0430\u0442\u044c\u0438\" title=\"\u041f\u0440\u0438\u043c\u0435\u0440 \u0442\u0435\u043a\u0441\u0442\u0430 \u0438\u0437 \u0441\u0442\u0430\u0442\u044c\u0438\" width=\"850\" height=\"277\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/214\/b67\/9c1\/214b679c1ae686fcebc8c5647ea71b6e.jpeg\" data-blurred=\"true\"\/><figcaption>\u041f\u0440\u0438\u043c\u0435\u0440 \u0442\u0435\u043a\u0441\u0442\u0430 \u0438\u0437 \u0441\u0442\u0430\u0442\u044c\u0438<\/figcaption><\/figure>\n<p>\u042f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043b \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0443 \u0432 \u0444\u043e\u043d\u043e\u0432\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u0435 \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0440\u0430\u0441\u0447\u0451\u0442\u044b, \u0438\u0437-\u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0430 \u0432 0.3 \u0441\u0435\u043a\u0443\u043d\u0434\u044b, \u0447\u0442\u043e, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0438 \u0441\u0442\u0430\u043b\u043e \u043a\u0440\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0447\u0430\u0441\u0442\u044c\u044e \u0434\u043b\u044f \u0436\u044e\u0440\u0438 \u043a\u043e\u043d\u043a\u0443\u0440\u0441\u0430. \u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u044d\u0442\u043e, \u0431\u044b\u043b\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0430 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044f \u0434\u043b\u044f \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u0441\u0442\u0440\u043e\u043a \u0438 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0448\u0438\u0440\u0438\u043d\u044b \u0432 \u0446\u0435\u043b\u043e\u043c.<\/p>\n<h2>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043c\u0430\u0440\u043a\u0435\u0440\u0430, \u043a\u0430\u0440\u0430\u043d\u0434\u0430\u0448\u0430 \u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u0430 \u043d\u0435\u043e\u043d\u0430<\/h2>\n<p>\u0414\u043b\u044f \u043d\u0435\u043e\u043d\u0430 \u043a \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u043c\u0443 \u043f\u0443\u0442\u0438 (\u0438 CAShapeLayer \u0432 \u0438\u0442\u043e\u0433\u0435) \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u0442\u0435\u043d\u044c, \u0447\u0442\u043e \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u043b\u043e \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u043d\u0443\u0436\u043d\u043e\u0433\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0430:<\/p>\n<pre><code class=\"swift\">layerTemp.shadowRadius = widthShadow layerTemp.shadowOpacity = shadowOpacity layerTemp.shadowColor = currentColor.cgColor<\/code><\/pre>\n<p>\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0434\u043b\u044f \u0448\u0438\u0440\u0438\u043d\u044b \u0442\u0435\u043d\u0438 \u0438 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u0438 \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0433\u043e \u0446\u0432\u0435\u0442\u0430.<\/p>\n<p>\u0414\u043b\u044f \u044d\u0444\u0444\u0435\u043a\u0442\u0430 \u043a\u0430\u0440\u0430\u043d\u0434\u0430\u0448\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d pattern \u043e\u0442 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438<\/p>\n<pre><code class=\"swift\">UIColor(patternImage: pencilImage).cgColor<\/code><\/pre>\n<p>\u0414\u043b\u044f \u043c\u0430\u0440\u043a\u0435\u0440\u0430 \u0436\u0435 \u0446\u0432\u0435\u0442 \u0441\u043b\u043e\u044f \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u044b\u043b \u0441 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0439 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u044c\u044e, \u0447\u0442\u043e \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u043b\u043e \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u043d\u0443\u0436\u043d\u043e\u0433\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0430.<\/p>\n<h2>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u044d\u0444\u0444\u0435\u043a\u0442\u0430 \u043b\u0430\u0441\u0442\u0438\u043a\u0430 (\u0438 \u0431\u044d\u043a\u0433\u0440\u0430\u0443\u043d\u0434 \u0431\u043b\u044e\u0440\u0430).<\/h2>\n<p>\u041e\u0434\u043d\u043e \u0438\u0437 \u043d\u0435\u043e\u0431\u044b\u0447\u043d\u044b\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u0439, \u043a\u0430\u043a \u043c\u043d\u0435 \u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u043b\u043e\u0441\u044c \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0432\u043c\u0435\u0441\u0442\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0435\u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u044f \u0441\u043b\u043e\u0451\u0432 \u0431\u044b\u043b\u043e \u0440\u0435\u0448\u0435\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443 \u043a\u0430\u043a \u043c\u0430\u0441\u043a\u0443 \u0438 \u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0439 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u043e\u0439 \u0432\u043c\u0435\u0441\u0442\u043e \u043b\u0430\u0441\u0442\u0438\u043a\u0430 (\u044d\u0444\u0444\u0435\u043a\u0442 \u0431\u0443\u0434\u0435\u0442 \u0442\u0435\u043c \u0436\u0435, \u0430 \u0441\u0438\u043b \u0437\u0430\u0442\u0440\u0430\u0447\u0435\u043d\u043e \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u043c\u0435\u043d\u044c\u0448\u0435!).<\/p>\n<p>\u0414\u043b\u044f \u0431\u044d\u043a\u0433\u0440\u0430\u0443\u043d\u0434 \u0431\u043b\u044e\u0440\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0441\u0445\u043e\u0436\u0435\u0435, \u043d\u043e \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u0443\u0441\u043b\u043e\u0432\u0438\u0435\u043c. \u0414\u043b\u044f \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0430\u043a\u043e\u0439 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0438 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0430.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u0442\u0435 \u043f\u043e\u0432\u0442\u043e\u0440\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u043f\u0443\u0442\u044c, \u0442\u043e \u0431\u0443\u0434\u044c\u0442\u0435 \u043e\u0441\u0442\u043e\u0440\u043e\u0436\u043d\u044b, \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u0447\u043d\u0451\u0442 \u043f\u0440\u043e\u0441\u0435\u0434\u0430\u0442\u044c \u043d\u0430 \u0431\u043e\u043b\u044c\u0448\u043e\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u0441\u043b\u043e\u0451\u0432.<\/p>\n<h2>\u0421\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 (\u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435) \u0432\u0438\u0434\u0435\u043e \u0441 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u043c\u0438<\/h2>\n<p>\u0414\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432\u0438\u0434\u0435\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0441\u0432\u044f\u0437\u043a\u0430 <code>AVPlayer\/AVPlayerLayer<\/code>. \u0421\u043b\u043e\u0439 \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432\u0438\u0434\u0435\u043e \u043d\u0430\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u043c \u043d\u0430 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443 \u0438 \u0437\u0430\u0446\u0438\u043a\u043b\u0438\u0432\u0430\u0435\u043c \u0435\u0433\u043e (\u0438\u043d\u0441\u0442\u0430\u0433\u0440\u0430\u043c-\u044d\u0444\u0444\u0435\u043a\u0442\u044b, \u043f\u0440\u0438\u0432\u0435\u0442).<\/p>\n<p>\u0414\u043b\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"swift\">let videoComp = AVMutableVideoComposition() videoComp.renderSize = videoSize videoComp.frameDuration = CMTimeMake(value: 1, timescale: 30) videoComp.animationTool = AVVideoCompositionCoreAnimationTool(postProcessingAsVideoLayer: videoLayer, in: parentLayer)  let instruction = AVMutableVideoCompositionInstruction()  instruction.timeRange = CMTimeRangeMake(start: CMTime.zero, duration: mixComposition.duration)<\/code><\/pre>\n<p><code>renderSize<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439, \u0442\u0430\u043a \u043a\u0430\u043a \u0432 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f\u0445 \u043a\u043e\u043d\u043a\u0443\u0440\u0441\u0430 \u0431\u044b\u043b\u043e \u0441\u043a\u0430\u0437\u0430\u043d\u043e \u043f\u0440\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0430\u0441\u0441\u0435\u0442\u043e\u0432 \u0432 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u043c \u0440\u0430\u0437\u043c\u0435\u0440\u0435.<\/p>\n<p><code>parentLayer<\/code> &#8212; \u0441\u043b\u043e\u0439, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u043d\u0430\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u043c \u0432\u0441\u0435 \u043d\u0430\u0448\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f.<\/p>\n<p>\u041a\u0440\u043e\u043c\u0435 \u044d\u0442\u043e\u0433\u043e, \u043a\u0440\u0430\u0439\u043d\u0435 \u0432\u0430\u0436\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u043c\u0430\u0441\u0448\u0442\u0430\u0431 \u0438 \u043d\u0435 \u043f\u043e\u0442\u0435\u0440\u044f\u0442\u044c \u043f\u0440\u043e\u043f\u043e\u0440\u0446\u0438\u0438 \u043f\u0440\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0438<\/p>\n<pre><code class=\"swift\">let scale : CGAffineTransform = CGAffineTransform(scaleX: videoSize.width \/ overlayLayer.bounds.width, y: videoSize.height \/ overlayLayer.bounds.height) overlayLayer.setAffineTransform(scale) layerInstruction.setTransform((clipVideoTrack.preferredTransform), at: CMTime.zero)  instruction.layerInstructions = [layerInstruction] videoComp.instructions = [instruction]<\/code><\/pre>\n<p>\u0413\u0430\u043b\u0435\u0440\u0435\u044f \u043e\u0431\u043d\u043e\u0432\u0438\u0442 \u043d\u0430\u0448\u0438 \u0430\u0441\u0441\u0435\u0442\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>PHPhotoLibraryChangeObserver.<\/code><\/p>\n<h2>\u0424\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<\/h2>\n<p>\u041f\u043e\u0436\u0430\u043b\u0443\u0439, \u043b\u0443\u0447\u0448\u0435 \u0432\u0441\u0435\u0433\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u0432\u0438\u0434\u0435\u043e, \u0447\u0442\u043e \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u0438\u0442\u043e\u0433\u0435<\/p>\n<details class=\"spoiler\">\n<summary>\u0412\u0438\u0434\u0435\u043e \u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u043e\u043c<\/summary>\n<div class=\"spoiler__content\">\n<div class=\"tm-iframe_temp\" data-src=\"https:\/\/embedd.srv.habr.com\/iframe\/636e144d0ca3379afa71674e\" data-style=\"\" id=\"636e144d0ca3379afa71674e\" width=\"\"><\/div>\n<\/p>\n<\/div>\n<\/details>\n<h2>\u0412\u044b\u0432\u043e\u0434\u044b \u043f\u043e\u0441\u043b\u0435 \u043a\u043e\u043d\u043a\u0443\u0440\u0441\u0430<\/h2>\n<p>\u0422\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e \u043f\u043b\u0430\u0432\u043d\u043e\u0441\u0442\u044c \u043b\u0438\u043d\u0438\u0439 \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u043d\u044b\u043c. \u0412\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043a \u0434\u0435\u0442\u0430\u043b\u044f\u043c, \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 \u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u043c \u0441\u0442\u043e\u0438\u043b\u043e \u043e\u0442\u043b\u043e\u0436\u0438\u0442\u044c. \u041a\u0430\u043a \u0441\u043e\u043e\u0431\u0449\u0430\u0435\u0442 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a, \u043c\u043e\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432 \u044d\u0442\u043e\u043c \u043a\u043e\u043d\u043a\u0443\u0440\u0441\u0435 \u2014 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u043f\u0440\u0438\u0437\u043e\u0432\u043e\u0433\u043e \u043c\u0435\u0441\u0442\u0430, \u043d\u043e \u043d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u044d\u0442\u043e, \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0432\u0435\u0440\u0438\u0442\u044c, \u0447\u0442\u043e \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u0441 \u043a\u043e\u043d\u043a\u0443\u0440\u0441\u043d\u044b\u043c \u0437\u0430\u0434\u0430\u043d\u0438\u0435\u043c \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u0435\u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u043e\u043f\u044b\u0442 \u0438 \u043f\u0440\u043e\u043a\u0430\u0447\u0430\u0442\u044c \u0437\u043d\u0430\u043d\u0438\u044f \u0441\u0440\u0430\u0437\u0443 \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043e\u0431\u043b\u0430\u0441\u0442\u044f\u0445.<\/p>\n<hr\/>\n<p>\u0427\u0442\u043e \u0436, \u0435\u0441\u043b\u0438 \u0432\u0430\u043c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b \u0442\u0430\u043a\u0438\u0435 \u0438\u0441\u0442\u043e\u0440\u0438\u0438, \u043f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0439\u0442\u0435\u0441\u044c <a href=\"https:\/\/t.me\/iOS_Career\" rel=\"noopener noreferrer nofollow\">\u043d\u0430 \u043c\u043e\u0439 \u043a\u0430\u043d\u0430\u043b \u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435,\u00a0\u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u0438 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432<\/a>.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/cba\/321\/a19\/cba321a196f31b8d2972eb682699e470.jpg\" alt=\"\u0410\u0432\u0442\u043e\u0440\u0441\u043a\u0438\u0439 \u043a\u0430\u043d\u0430\u043b \u043e\u0431 iOS-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435\" title=\"\u0410\u0432\u0442\u043e\u0440\u0441\u043a\u0438\u0439 \u043a\u0430\u043d\u0430\u043b \u043e\u0431 iOS-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435\" width=\"959\" height=\"123\" data-src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/cba\/321\/a19\/cba321a196f31b8d2972eb682699e470.jpg\" data-blurred=\"true\"\/><figcaption>\u0410\u0432\u0442\u043e\u0440\u0441\u043a\u0438\u0439 \u043a\u0430\u043d\u0430\u043b \u043e\u0431 iOS-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435<\/figcaption><\/figure>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/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\/articles\/698790\/\"> https:\/\/habr.com\/ru\/articles\/698790\/<\/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 article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><figcaption>\u041a\u043e\u043d\u043a\u0443\u0440\u0441 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c \u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043c\u0435\u0434\u0438\u0430\u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0430<\/figcaption><\/figure>\n<p>\u0417\u0430\u0434\u0430\u0447\u0430 \u0441\u043e\u0441\u0442\u043e\u044f\u043b\u0430 \u0432 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0430\u0432\u0442\u043e\u043d\u043e\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u0435\u0434\u0438\u0430\u0444\u0430\u0439\u043b\u043e\u0432 \u043d\u0430 Swift <strong>\u0431\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0445 UI-\u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u0432<\/strong>. \u041a\u043e\u043d\u043a\u0443\u0440\u0441\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u044b \u0441 \u043d\u0443\u043b\u044f. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439 \u043c\u0435\u0434\u0438\u0430\u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u043e\u0432 \u0441 \u043f\u043e\u0445\u043e\u0436\u0438\u043c\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438 \u0441\u0442\u0440\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u0435\u0449\u0435\u043d\u043e. <\/p>\n<p>\u041f\u043b\u0430\u0432\u043d\u043e\u0441\u0442\u044c \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 \u0438 \u043e\u0431\u0449\u0430\u044f \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0443\u0442 \u0438\u0433\u0440\u0430\u0442\u044c \u0432\u0430\u0436\u043d\u0443\u044e \u0440\u043e\u043b\u044c. \u0418 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435, \u043d\u043e \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 \u0432\u0430\u0436\u043d\u043e\u0435 \u2014 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u043e\u0432 (\u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0441\u0431\u043e\u0438, \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e, \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b, \u0437\u0430\u043c\u0435\u0442\u043d\u043e\u0435 \u043c\u0438\u0433\u0430\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u043d\u0435\u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u0441\u0442\u0432\u043e \u043c\u0430\u043a\u0435\u0442\u0430 \u0438 \u043c\u043d\u043e\u0433\u043e\u0435 \u0434\u0440\u0443\u0433\u043e\u0435).<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0443\u0437\u043d\u0430\u0442\u044c, \u0447\u0442\u043e \u0436\u0435 \u0431\u044b\u043b\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043e, \u043a\u0430\u043a\u0438\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u0438 \u0432\u044b\u0432\u043e\u0434\u044b \u044f \u0441\u0434\u0435\u043b\u0430\u043b \u043f\u043e\u0441\u043b\u0435 \u043a\u043e\u043d\u043a\u0443\u0440\u0441\u0430, \u0442\u043e \u0437\u0430\u0445\u043e\u0434\u0438\u0442\u0435. <\/p>\n<p><strong>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/strong>. \u0415\u0441\u043b\u0438 \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0439, \u0442\u043e\u00a0<a href=\"https:\/\/t.me\/+qll_YZ6_8bo2Njky\" rel=\"noopener noreferrer nofollow\">\u0432\u043e\u0442 \u0442\u0443\u0442 \u044f \u043f\u0438\u0448\u0443 \u043e\u0431 iOS-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435<\/a>\u00a0\u0438 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0441 \u043d\u0435\u0439 \u0441\u0432\u044f\u0437\u0430\u043d\u043e.<\/p>\n<hr\/>\n<h2>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u0438 \u043e\u0446\u0435\u043d\u043a\u0430 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u0441\u0438\u043b \u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439<\/h2>\n<p>\u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0439 \u044f\u0432\u043b\u044f\u043b\u0430\u0441\u044c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 iOS 13 \u0438 \u0432\u044b\u0448\u0435, \u0442\u043e \u043c\u043d\u043e\u0433\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0430, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u0432\u044b\u0431\u043e\u0440\u0430 \u0446\u0432\u0435\u0442\u043e\u0432 <code>UIColorPickerViewController<\/code> \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e. <\/p>\n<p>\u0414\u043b\u044f \u0433\u0430\u043b\u0435\u0440\u0435\u0438 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e\u0441\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0441 \u043f\u043b\u0430\u0432\u043d\u043e\u0439 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0435\u0439 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e pinchgesture \u0432 \u0441\u0442\u0438\u043b\u0435 \u044d\u043f\u043b\u043e\u0432\u0441\u043a\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f Photos.<\/p>\n<p>\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0438 \u043d\u0435\u043c\u0430\u043b\u043e\u0432\u0430\u0436\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u0441\u0442\u0430 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u043b\u0430\u0441\u044c \u0432 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0438 \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0438\u0437 \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u044b\u0445 \u043c\u0430\u043a\u0435\u0442\u043e\u0432 \u0442\u0430\u043a \u0438\u043b\u0438 \u0438\u043d\u0430\u0447\u0435 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0431\u044b \u043e\u0442\u043b\u043e\u0436\u0438\u0442\u044c \u043d\u0430 \u0431\u0443\u0434\u0443\u0449\u0435\u0435.<\/p>\n<p>\u0421\u0430\u043c\u044b\u043c \u0432\u0430\u0436\u043d\u044b\u043c (\u0438 \u043a\u0440\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043a\u0430\u043a \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u0437\u0436\u0435) \u0441\u0442\u0430\u043b\u0430 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0430 \u043b\u0438\u043d\u0438\u0438, \u0430 \u0432\u0441\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0442\u0438\u043f\u0430 \u043a\u0430\u0440\u0430\u043d\u0434\u0430\u0448\u0430, \u043c\u0430\u0440\u043a\u0435\u0440\u0430 \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435 \u0438\u043c\u0435\u043b\u0438 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043c\u0435\u043d\u044c\u0448\u0438\u0439 \u0438\u043c\u043f\u0430\u043a\u0442 \u043d\u0430 \u0438\u0442\u043e\u0433\u043e\u0432\u0443\u044e \u043e\u0446\u0435\u043d\u043a\u0443.<\/p>\n<p>\u0412 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u0445 \u043a\u043e\u043d\u043a\u0443\u0440\u0441 \u0431\u044b\u043b\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u0438 \u043f\u0440\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u043d\u0430\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u043d\u0430 \u0432\u0438\u0434\u0435\u043e \u0432 \u0433\u0430\u043b\u0435\u0440\u0435\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u043d\u043e \u043e\u0431 \u044d\u0442\u043e\u043c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0437\u0436\u0435.<\/p>\n<p>\u041a\u0440\u043e\u043c\u0435 \u044d\u0442\u043e\u0433\u043e, \u0432\u0430\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 \u043a \u0432\u0438\u0434\u0443, \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u043c\u0443 \u043d\u0430 <a href=\"https:\/\/t.me\/contest\/304\" rel=\"noopener noreferrer nofollow\">\u0432\u0438\u0434\u0435\u043e<\/a>.<\/p>\n<h2>\u0413\u0430\u043b\u0435\u0440\u0435\u044f (\u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0444\u043e\u0442\u043e \u0438 \u0432\u0438\u0434\u0435\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f)<\/h2>\n<p>\u0422\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0435 \u2014 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440, \u0435\u0441\u043b\u0438 \u043d\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u0430, \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u044b \u043c\u0435\u0436\u0434\u0443 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u0442\u0438\u043f\u0430 \u043b\u044d\u0439\u0430\u0443\u0442\u0430 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0436\u0435\u0441\u0442\u043e\u0432.<\/p>\n<p>\u0414\u043b\u044f \u044d\u043a\u0440\u0430\u043d\u0430 \u0441 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u043e \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 Lotti\u0435 (\u0438\u043b\u0438 rlottie \u2014 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0435\u0433\u043e, \u0442\u0430\u043a \u043a\u0430\u043a \u0432 \u0441\u0432\u043e\u0438\u0445 \u0440\u0430\u0431\u043e\u0447\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u0434\u043b\u044f \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0435\u0439 \u043e\u043d \u0432\u044b\u0438\u0433\u0440\u044b\u0432\u0430\u0435\u0442 \u043f\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438).<\/p>\n<p>\u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 \u0441\u0432\u0430\u0439\u043f\u043e\u0432 \u043e\u043f\u0438\u0440\u0430\u043b\u0441\u044f \u043d\u0430 <code>UIPinchGestureRecognizer<\/code> \u0438 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u043c\u0430\u0441\u0448\u0442\u0430\u0431. <\/p>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u043c \u0442\u0435\u043a\u0443\u0449\u0443\u044e \u044f\u0447\u0435\u0439\u043a\u0443, \u0430 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0441\u0432\u0430\u0439\u043f\u0430 \u043f\u0435\u0440\u0435\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c \u043b\u044d\u0439\u0430\u0443\u0442 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u0430 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<pre><code class=\"swift\">let potentialScale:CGFloat = min(maxScale, max(scaleStart * pinchReco.scale, minScale)) let scaleToRound: Double = potentialScale let scale = scaleToRound.round(nearest: 0.05) if scale != currentScale {     currentScale = scale     \u0441vGallery.collectionViewLayout.invalidateLayout()     guard let path = pathToScroll else {         return     }     cvGallery.scrollToItem(at: path, at: .centeredVertically, animated: false) }<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 \u043a\u043e\u043d\u043a\u0443\u0440\u0441\u0430\u043d\u0442\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 <strong>\u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0439 \u0440\u0430\u0441\u0447\u0451\u0442<\/strong>,<strong> <\/strong>\u043d\u043e \u0442\u0430\u043a \u043a\u0430\u043a \u0434\u043b\u044f \u0441\u0435\u0431\u044f \u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043b\u0438\u043b \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442 \u043d\u0430 \u043c\u0435\u0434\u0438\u0430\u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440, \u0442\u043e \u043d\u0430 \u044d\u0442\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u0432 \u0433\u0430\u043b\u0435\u0440\u0435\u0435 \u044f \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0441\u044f.<\/p>\n<p>\u0421\u0430\u043c\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043a \u0433\u0430\u043b\u0435\u0440\u0435\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u0447\u0435\u0440\u0435\u0437 <code>fetchAssetCollections<\/code>, \u0430 \u043c\u0435\u0434\u0438\u0430\u0444\u0430\u0439\u043b\u044b \u043a\u044d\u0448\u0438\u043b\u0438\u0441\u044c \u0447\u0435\u0440\u0435\u0437 <code>PHImageManager<\/code>. \u0412 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043b\u044d\u0439\u0430\u0443\u0442\u0430 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u043b\u0441\u044f \u0440\u0430\u0437\u043c\u0435\u0440 \u0434\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u043f\u043b\u0430\u0432\u043d\u043e\u0433\u043e \u0441\u043a\u0440\u043e\u043b\u043b\u0430 \u0438 \u0432 \u0446\u0435\u043b\u043e\u043c \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>\u041a\u0440\u043e\u043c\u0435 \u044d\u0442\u043e\u0433\u043e, \u0434\u043b\u044f \u043a\u0435\u0439\u0441\u043e\u0432 \u0441 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438 \u044f\u0447\u0435\u0439\u043a\u0430\u043c\u0438 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e\u0441\u044c \u0441\u043a\u0440\u044b\u0432\u0430\u043b\u0430\u0441\u044c \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0430\u0441\u0441\u0435\u0442\u043e\u0432.<\/p>\n<h2>\u041c\u0435\u0434\u0438\u0430\u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440<\/h2>\n<p>\u0412 \u044d\u0442\u043e\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0435 \u043f\u043e\u0439\u0434\u0451\u0442 \u0440\u0435\u0447\u044c \u043e \u043f\u0440\u0438\u043d\u044f\u0442\u044b\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u044f\u0445, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441 \u0432\u044b\u0431\u043e\u0440\u043e\u043c \u0446\u0432\u0435\u0442\u0430, \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u043e\u0439 \u043b\u0438\u043d\u0438\u0438, \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u043c \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0435 \u0438 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0438 \u0432\u0441\u0435\u0433\u043e \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0433\u043e.<\/p>\n<h4>\u0412\u044b\u0431\u043e\u0440 \u0446\u0432\u0435\u0442\u0430<\/h4>\n<p>\u0411\u044b\u043b\u043e \u043f\u0440\u0438\u043d\u044f\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0432\u0441\u0451 \u0441 \u043d\u0443\u043b\u044f, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0445\u043e\u043b\u0441\u0442\u043e\u043c, \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c \u0438 \u0441\u043b\u043e\u044f\u043c\u0438,  \u0442\u0430\u043a\u0436\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0434\u043b\u044f \u0432\u044b\u0431\u043e\u0440\u0430 \u0446\u0432\u0435\u0442\u0430:<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0432\u044b\u0431\u043e\u0440\u0430 \u0446\u0432\u0435\u0442\u0430 \u0432 \u043c\u043e\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438?<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0414\u043b\u044f \u043f\u043e\u0432\u0442\u043e\u0440\u0435\u043d\u0438\u044f \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0440\u0438 \u0440\u0430\u0437\u0434\u0435\u043b\u0430: grid, spectrum \u0438 sliders.<\/p>\n<\/div>\n<\/details>\n<h4>\u042d\u043a\u0440\u0430\u043d \u0441 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u0442\u0438\u043f\u043e\u0432 \u0432\u044b\u0431\u043e\u0440\u0430 \u0446\u0432\u0435\u0442\u0430<\/h4>\n<p>\u042f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b \u0435\u0433\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>UIStackView + UIPageViewController.<\/code> \u0412 \u0441\u0442\u044d\u043a\u0432\u044c\u044e \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f, \u0441\u043f\u0435\u043a\u0442\u0440 (\u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 \u0438 \u0436\u0435\u0441\u0442\u0430 \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u0437\u0438\u0446\u0438\u0438) \u0438\u043b\u0438 \u0436\u0435 \u043d\u0430\u0431\u043e\u0440 \u0441\u043b\u0430\u0439\u0434\u0435\u0440\u043e\u0432 \u0441 \u043f\u043e\u043b\u044f\u043c\u0438 \u0432\u0432\u043e\u0434\u0430.<\/p>\n<p>\u0414\u043b\u044f \u0441\u043b\u0430\u0439\u0434\u0435\u0440\u0430 \u0438 \u0448\u0430\u0445\u043c\u0430\u0442\u043a\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b:<\/p>\n<details class=\"spoiler\">\n<summary>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0448\u0430\u0445\u043c\u0430\u0442\u043a\u0438 \u0432 \u0441\u043b\u0430\u0439\u0434\u0435\u0440\u0435<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"swift\">private func renderCheckerboardPattern(colors: (dark: UIColor, light: UIColor), height:CGFloat) -> UIColor {     let size = height\/3     let image = UIGraphicsImageRenderer(size: CGSize(width: size * 2, height: size * 2)).image { context in         colors.dark.setFill()         context.fill(CGRect(x: 0, y: 0, width: size * 2, height: size * 2))         colors.light.setFill()         context.fill(CGRect(x: size, y: 0, width: size, height: size))         context.fill(CGRect(x: 0, y: size, width: size, height: size))     }     return UIColor(patternImage: image) }<\/code><\/pre>\n<p>\u0412\u044b\u0441\u043e\u0442\u0430 \u0434\u0435\u043b\u0438\u0442\u0441\u044f \u043d\u0430 3, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0443\u0436\u043d\u043e \u0442\u0440\u0438 \u0440\u044f\u0434\u0430. \u0421\u0430\u043c\u0443 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443 \u0433\u0435\u043d\u0435\u0440\u0438\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>UIGraphicsImageRenderer.<\/code><\/p>\n<\/div>\n<\/details>\n<p>\u041a\u0430\u043a \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442\u0441\u044f \u0446\u0432\u0435\u0442\u0430 \u0441\u043b\u0435\u0432\u0430 \u0438 \u0441\u043f\u0440\u0430\u0432\u0430 \u043d\u0430 \u0441\u043b\u0430\u0439\u0434\u0435\u0440\u0430\u0445, \u0434\u043e \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u043d\u043a\u0443\u0440\u0441\u0430 \u043d\u0435 \u0437\u043d\u0430\u043b, \u043d\u043e \u0440\u0430\u0434\u0438 \u044d\u0442\u043e\u0433\u043e \u0438 \u0441\u0442\u043e\u0438\u0442 \u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c, \u0440\u0430\u0437\u0432\u0435 \u043d\u0435\u0442? \u0412 \u0438\u0442\u043e\u0433\u0435 \u0431\u044b\u043b\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0445 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u043e\u0432 \u0441\u043b\u0430\u0439\u0434\u0435\u0440\u0430:<\/p>\n<pre><code class=\"swift\">var rgba: (red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat) {     var red: CGFloat = 0     var green: CGFloat = 0     var blue: CGFloat = 0     var alpha: CGFloat = 0     getRed(&amp;red, green: &amp;green, blue: &amp;blue, alpha: &amp;alpha)          return (red, green, blue, alpha) }  func max(red:Bool = false, green:Bool = false, blue:Bool = false) -> UIColor {     let rgba = self.rgba     return UIColor(red: red ? 1 : rgba.red, green: green ? 1 : rgba.green, blue: blue ? 1 : rgba.blue, alpha: rgba.alpha) }  func min(red:Bool = false, green:Bool = false, blue:Bool = false) -> UIColor {     let rgba = self.rgba     return UIColor(red: red ? 0 : rgba.red, green: green ? 0 : rgba.green, blue: blue ? 0 : rgba.blue, alpha: rgba.alpha) }  static func colorFrom(rgba: (red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat)) -> UIColor {     return UIColor(red: rgba.red, green: rgba.green, blue: rgba.blue, alpha: rgba.alpha) }<\/code><\/pre>\n<p>\u041d\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u044e, \u0447\u0442\u043e \u0435\u0441\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0449\u0435, \u043d\u043e \u044f \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u043b, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043c\u044b \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u043c \u0446\u0432\u0435\u0442\u043e\u043c, \u0442\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0435\u043c\u0443 0 \u0438 1 \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0446\u0432\u0435\u0442\u0430 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043d\u0443\u0436\u043d\u043e\u0433\u043e.<\/p>\n<p>\u0414\u043b\u044f \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u043d\u0443\u0436\u043d\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f <code>UITextField<\/code> (\u0430 \u0447\u0442\u043e \u0436\u0435 \u0435\u0449\u0451).<\/p>\n<h4>\u0421\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0446\u0432\u0435\u0442\u0430\u043c\u0438<\/h4>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c UIPageViewController \u0441 \u0440\u0430\u0441\u0447\u0451\u0442\u043e\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0446\u0432\u0435\u0442\u043e\u0432 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443. <\/p>\n<pre><code class=\"swift\">func chunked(into size: Int) -> [[Element]] {     return stride(from: 0, to: count, by: size).map {         Array(self[$0 ..&lt; Swift.min($0 + size, count)])     } }<\/code><\/pre>\n<p>\u041f\u0440\u0438 \u0432\u044b\u0445\u043e\u0434\u0435 \u0441 \u044d\u043a\u0440\u0430\u043d\u0430 \u043c\u0430\u0441\u0441\u0438\u0432 \u0446\u0432\u0435\u0442\u043e\u0432 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u0432 <code>UserDefaults<\/code> \u0432 \u0432\u0438\u0434\u0435 <strong>hex-\u0441\u0442\u0440\u043e\u043a\u0438<\/strong>. \u0418\u0437 \u043d\u0435\u0451 \u0436\u0435 \u0438 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0435 \u0446\u0432\u0435\u0442\u0430 \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c.<\/p>\n<h4>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0438\u043f\u0435\u0442\u043a\u0438 (\u043e\u043d\u043e \u0436\u0435 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0441\u0442\u0435\u043a\u043b\u043e, \u0438\u043b\u0438 \u0436\u0435 \u043b\u0443\u043f\u0430)<\/h4>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b \u0441\u0432\u044f\u0437\u043a\u0443 \u0438\u0437 \u0436\u0435\u0441\u0442\u0430 \u0438 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u043c\u0430\u0433\u043d\u0438\u0444\u0430\u0439-\u044d\u0444\u0444\u0435\u043a\u0442\u0430 \u0432 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0435.<\/p>\n<pre><code class=\"swift\">public override func draw(_ rect: CGRect) {     guard let context = UIGraphicsGetCurrentContext() else { return }      context.translateBy(x: radius, y: radius)     context.scaleBy(x: scale, y: scale)     context.translateBy(x: -magnifiedPoint.x, y: -magnifiedPoint.y)     context.interpolationQuality = .none     removeFromSuperview()     magnifiedView?.layer.render(in: context)     magnifiedView?.superview?.addSubview(self) }<\/code><\/pre>\n<p>\u0410\u0445 \u0434\u0430, \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043d\u0435\u043e\u0431\u044b\u0447\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043e\u0442 \u0434\u0438\u0437\u0430\u0439\u043d\u0435\u0440\u043e\u0432 Telegram \u043e\u0442 \u0447\u0451\u0440\u043d\u043e\u0433\u043e \u043a \u043d\u0443\u0436\u043d\u043e\u043c\u0443. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0431\u044b\u043b\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>CIFilter<\/code>:<\/p>\n<pre><code class=\"swift\">  static func filteredImage(cgImage: CGImage, size:CGSize) -> UIImage? {       if let matrixFilter = CIFilter(name: \"CIColorMatrix\") {           matrixFilter.setDefaults()           matrixFilter.setValue(CIImage(cgImage: cgImage), forKey: kCIInputImageKey)           let rgbVector = CIVector(x: 0, y: 0, z: 0, w: 0)           let aVector = CIVector(x: 1, y: 1, z: 1, w: 0)           matrixFilter.setValue(rgbVector, forKey: \"inputRVector\")           matrixFilter.setValue(rgbVector, forKey: \"inputGVector\")           matrixFilter.setValue(rgbVector, forKey: \"inputBVector\")           matrixFilter.setValue(aVector, forKey: \"inputAVector\")           matrixFilter.setValue(CIVector(x: 1, y: 1, z: 1, w: 0), forKey: \"inputBiasVector\")            if let matrixOutput = matrixFilter.outputImage, let cgImage = CIContext().createCGImage(matrixOutput, from: matrixOutput.extent) {               return UIImage(cgImage: cgImage).resizedImage(with: size)           }        }       return nil   }<\/code><\/pre>\n<p>\u0422\u043e \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c, \u043f\u043e\u0434 \u0441\u043f\u043e\u0439\u043b\u0435\u0440\u043e\u043c \u043d\u0438\u0436\u0435.<\/p>\n<details class=\"spoiler\">\n<summary>\u0410 \u0432\u043e\u0442 \u0442\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u044d\u0442\u043e\u0442 \u044d\u0444\u0444\u0435\u043a\u0442 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<h4>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u0434\u043b\u044f \u0432\u044b\u0431\u043e\u0440\u0430 \u0446\u0432\u0435\u0442 \u0441 \u044d\u043a\u0440\u0430\u043d\u0430 \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u044f<\/h4>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u0434\u0435\u043b\u0430\u043b \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b \u0441 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439 \u0434\u0432\u0443\u0445 \u0436\u0435\u0441\u0442\u043e\u0432 (\u0434\u043b\u044f \u0434\u043b\u0438\u043d\u043d\u043e\u0433\u043e \u043a\u0430\u0441\u0430\u043d\u0438\u044f \u0438 \u043a\u043e\u0440\u043e\u0442\u043a\u043e\u0433\u043e \u2014 \u0434\u043b\u044f \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f \u043f\u0438\u043a\u0435\u0440\u0430).<\/p>\n<pre><code class=\"swift\">  func addShortAndLongTaps(needShort:Bool = false, needLong:Bool = false) {       if needShort {           let tapGesture = UITapGestureRecognizer(target: self, action: #selector(onShort))           addGestureRecognizer(tapGesture)       }        if needLong {           let longGesture = UILongPressGestureRecognizer(target: self, action: #selector(onLong))           longGesture.minimumPressDuration = 0.3           addGestureRecognizer(longGesture)       }   }<\/code><\/pre>\n<h2>\u0410\u043d\u0438\u043c\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a\u0430\u0440\u0430\u043d\u0434\u0430\u0448\u0435\u0439 (\u0438 \u0438\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f)<\/h2>\n<details class=\"spoiler\">\n<summary>\u0427\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c<\/summary>\n<div class=\"spoiler__content\">\n<div class=\"tm-iframe_temp\" data-src=\"https:\/\/embedd.srv.habr.com\/iframe\/636e02766dab065090ebff98\" data-style=\"\" id=\"636e02766dab065090ebff98\" width=\"\"><\/div>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0411\u0430\u0437\u0430 \u2014 \u044d\u0442\u043e <code>UICollectionView<\/code> \u0441 \u044f\u0447\u0435\u0439\u043a\u0430\u043c\u0438 \u043d\u0430 \u0430\u0432\u0442\u043e\u043b\u044d\u0439\u0430\u0443\u0442\u0435. \u0421\u0430\u043c\u0430 \u044f\u0447\u0435\u0439\u043a\u0430 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0444\u043e\u043d\u0430 \u0434\u043b\u044f \u043a\u0430\u0440\u0430\u043d\u0434\u0430\u0448\u0430, \u043e\u0432\u0435\u0440\u043b\u044d\u044f (\u0433\u0440\u0438\u0444\u0435\u043b\u044c) \u0438 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u0434\u043b\u044f \u0442\u043e\u0449\u0438\u043d\u044b \u043a\u0430\u0440\u0430\u043d\u0434\u0430\u0448\u0430.<\/p>\n<p>\u0414\u043b\u044f \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 \u0440\u0435\u0448\u0438\u043b \u0441\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u044f\u0447\u0435\u0439\u043a\u0438 \u0447\u0435\u0440\u0435\u0437 \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u0435 \u0432\u044b\u0441\u043e\u0442\u044b \u043a\u0430\u0440\u0430\u043d\u0434\u0430\u0448\u0435\u0439 \u0441 \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u043e\u0439 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0438\u0445 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u0432 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0441 \u0432\u044b\u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0435\u043c \u043d\u0443\u0436\u043d\u043e\u0433\u043e \u043d\u0430 \u043f\u043e\u0437\u0438\u0446\u0438\u044e \u043f\u043e\u0441\u0435\u0440\u0435\u0434\u0438\u043d\u0435 (\u0447\u0435\u0440\u0435\u0437 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043f\u043e\u0437\u0438\u0446\u0438\u0439 \u044f\u0447\u0435\u0435\u043a). \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0442\u0430\u043a\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u043b\u0430\u0432\u043d\u043e\u0435 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435 \u0442\u043e\u043b\u0449\u0438\u043d\u044b \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u0430.<\/p>\n<p>\u0414\u043b\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u043b\u0430\u0441\u0442\u0438\u043a\u0430 \u0442\u0430\u043a\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 (\u0431\u043b\u044e\u0440 \u0438\u043b\u0438 \u0441\u0442\u0438\u0440\u0430\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432).<\/p>\n<p>\u041f\u0440\u0438 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u043c\u0435\u0436\u0434\u0443 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u043c\u0438 \u0440\u0435\u0436\u0438\u043c\u0430\u043c\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u044f<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\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-392165","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/392165","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=392165"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/392165\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=392165"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=392165"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=392165"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}