{"id":320391,"date":"2021-03-27T21:01:19","date_gmt":"2021-03-27T21:01:19","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=320391"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=320391","title":{"rendered":"iOS. UI. \u041f\u0440\u0438\u00eb\u043c\u044b. \u0427\u0430\u0441\u0442\u044c 1"},"content":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044f\u043c \u0425\u0430\u0431\u0440\u0430!<\/p>\n<p>\u042f iOS-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a, \u0438 \u0442\u0430\u043a \u0441\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u043c\u043d\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u043c\u043d\u043e\u0433\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0432 ui: \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0435 view, \u0442\u0435\u043d\u0438, layout-\u044b, \u043a\u043d\u043e\u043f\u043a\u0438 \u0438 \u0432\u043e\u0442 \u044d\u0442\u043e \u0432\u0441\u0451. \u0412 \u044d\u0442\u043e\u0439 \u0438 \u043f\u0430\u0440\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0441\u0442\u0430\u0442\u0435\u0439 \u0445\u043e\u0447\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043f\u0440\u0438\u0451\u043c\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043c\u043e\u0433\u0430\u043b\u0438 \u043c\u043d\u0435 \u0434\u043e\u0431\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0432\u0435\u0441\u044c\u043c\u0430 \u043a\u0440\u0430\u0441\u0438\u0432\u044b\u0445 \u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0445 \u044d\u0444\u0444\u0435\u043a\u0442\u043e\u0432 \u0432 \u043f\u043b\u0430\u043d\u0435 \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 ui. \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u043a\u043e\u043c\u0443-\u043d\u0438\u0431\u0443\u0434\u044c \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u043e. \u041d\u0443 \u0438\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e.<\/p>\n<h2>\u041d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0432\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h2>\n<p>\u041d\u0435 \u0431\u0435\u0440\u0443\u0441\u044c \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u0437\u0430 \u0432\u0441\u0435\u0445, \u043d\u043e, \u0438\u0441\u0445\u043e\u0434\u044f \u0438\u0437 \u043b\u0438\u0447\u043d\u043e\u0433\u043e \u043e\u043f\u044b\u0442\u0430, \u0441\u043b\u043e\u0436\u0438\u043b\u043e\u0441\u044c \u0432\u043f\u0435\u0447\u0430\u0442\u043b\u0435\u043d\u0438\u0435, \u0447\u0442\u043e \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u0430\u043a\u0438\u0445-\u0442\u043e &#171;\u043f\u043b\u0430\u0448\u0435\u043a&#187; \u0441 \u043d\u0435\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u043c\u0438 \u0444\u043e\u0440\u043c\u043e\u0439 \u0438 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435\u043c \u2013 \u043a\u0440\u0430\u0439\u043d\u0435 \u043d\u0435\u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430. \u041a\u0442\u043e-\u0442\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u0432 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0435, \u043a\u0442\u043e-\u0442\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u0440\u043e &#171;\u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0431\u0438\u0437\u043d\u0435\u0441\u0443 \u0445\u043e\u0440\u043e\u0448\u043e&#187; \u0441 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0443\u0441\u0438\u043b\u0438\u044f\u043c\u0438 (\u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043f\u0440\u043e\u0441\u044f\u0442 \u043f\u043e\u0443\u043c\u0435\u0440\u0438\u0442\u044c \u043f\u044b\u043b \u0434\u0438\u0437\u0430\u0439\u043d\u0435\u0440\u043e\u0432) \u0438 \u0442.\u043f. \u0418 \u0435\u0441\u043b\u0438 \u0443\u0436 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0434\u0435\u043b\u0430\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0438\u0437 \u0440\u044f\u0434\u0430 \u0432\u043e\u043d, \u0442\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f google, stackoverflow, \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u044b \u0438 \u0442.\u0434., \u0447\u0442\u043e \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u043d\u0435\u043c\u0430\u043b\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u0438 \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0449\u0443\u0449\u0435\u043d\u0438\u0435, \u0447\u0442\u043e \u043e\u043d\u043e \u0442\u043e\u0433\u043e \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435 \u0441\u0442\u043e\u0438\u0442. \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u044d\u0442\u0443 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0441\u0435\u0440\u0438\u044e \u0441\u0442\u0430\u0442\u0435\u0439 \u044f \u0438 \u0437\u0430\u0434\u0443\u043c\u0430\u043b \u043a\u0430\u043a \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0441\u043f\u0440\u0430\u0432\u043a\u0443, \u043f\u0440\u043e\u0447\u0442\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0441\u043d\u0438\u043c\u0435\u0442 \u0440\u044f\u0434 \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432 \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u043e\u0446\u0435\u043d\u0438\u0432\u0430\u0442\u044c\/\u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u043d\u0435\u0442\u0438\u043f\u0438\u0447\u043d\u044b\u0435 ui-\u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b. \u041d\u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u043a\u0430\u043a, \u0447\u0442\u043e \u0438 \u043f\u043e\u0447\u0435\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c.<\/p>\n<h2>\u041f\u0440\u0438\u043c\u0435\u0440 1: view \u0441 \u043d\u0435\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u043c\u0438 \u0433\u0440\u0430\u043d\u0438\u0446\u0435\u0439 \u0438 \u0442\u0435\u043d\u044c\u044e<\/h2>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/9ab\/c17\/aac\/9abc17aac29348d6cda15af3f1b6cf0a.png\" width=\"2208\" height=\"1242\"><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u0434\u0435\u044f \u043f\u0440\u043e\u0441\u0442\u0430\u044f: \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0435\u0449\u0451 \u043e\u0434\u0438\u043d \u0441\u043b\u043e\u0439 \u0432 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u044e \u0441\u043b\u043e\u0451\u0432 \u043d\u0430\u0448\u0435\u0439 view, \u043f\u043e\u0440\u0435\u0437\u0430\u0442\u044c \u0433\u0440\u0430\u043d\u0438\u0446\u044b \u0443 \u044d\u0442\u043e\u0433\u043e \u0441\u043b\u043e\u044f, \u0430 \u0444\u043e\u0440\u043c\u0443 \u0442\u0435\u043d\u0438 (\u0443\u0436\u0435 \u0443 \u0441\u0430\u043c\u043e\u0439 view) \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0440\u043e\u0432\u043d\u043e \u0442\u0430\u043a\u043e\u0439 \u0436\u0435, \u043a\u0430\u043a \u0438 \u0444\u043e\u0440\u043c\u0430 \u0433\u0440\u0430\u043d\u0438\u0446\u044b \u0441\u043b\u043e\u044f.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0447\u0443\u0442\u044c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435. \u0423 CALayer \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <strong>mask<\/strong>.<strong> <\/strong>\u0412 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u043e \u0442\u043e\u0442 \u0436\u0435 \u0441\u0430\u043c\u044b\u0439 \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 CALayer, \u0438 \u0435\u0441\u043b\u0438 \u043e\u043d \u043d\u0435 nil, \u0442\u043e \u0435\u0433\u043e \u0430\u043b\u044c\u0444\u0430-\u043a\u0430\u043d\u0430\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u043c\u0430\u0441\u043a\u0430 \u0434\u043b\u044f \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e layer. \u0422\u043e \u0435\u0441\u0442\u044c \u0435\u0441\u043b\u0438 \u0432\u0437\u044f\u0442\u044c png-\u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443 \u0441 \u043a\u043e\u0442\u043e\u043c \u0438 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u044c\u044e \u0438 \u043a\u0430\u043a\u0438\u043c-\u0442\u043e \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0437\u0430\u0441\u0443\u043d\u0443\u0442\u044c \u0435\u0435 \u0432 CALayer (\u043d\u0430\u0437\u043e\u0432\u0435\u043c \u0435\u0433\u043e catLayer), \u0442\u043e \u043f\u0440\u0438 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u043d\u0438\u0438<strong> layer.mask = catLayer<\/strong> \u043a\u043e\u043d\u0442\u0435\u043d\u0442 \u043d\u0430\u0448\u0435\u0433\u043e \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e layer \u0431\u0443\u0434\u0435\u0442 \u0432 \u0432\u0438\u0434\u0435 \u043a\u043e\u0442\u0430, \u0447\u0442\u043e \u0431\u044b \u043d\u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u0443 \u043d\u0435\u0433\u043e \u0432\u043d\u0443\u0442\u0440\u0438. \u041c\u043e\u0436\u0435\u0442, \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0439 \u043a\u043e\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f, \u0435\u0441\u043b\u0438 \u0432\u043d\u0443\u0442\u0440\u0438 layer \u043c\u043d\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0430. \u0412 \u043d\u0430\u0448\u0435\u043c \u0436\u0435 \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0443\u0436\u0435\u043d layer-\u043c\u0430\u0441\u043a\u0430 \u0432 \u0432\u0438\u0434\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0444\u0438\u0433\u0443\u0440\u044b. \u0422\u0443\u0442 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043c\u043e\u0447\u044c <strong>CAShapeLayer<\/strong> &#8212; \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a CALayer, \u043a\u043e\u0442\u043e\u0440\u044b\u0439, \u0433\u0440\u0443\u0431\u043e \u0433\u043e\u0432\u043e\u0440\u044f, \u0443\u043c\u0435\u0435\u0442 \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u0435\u0431\u044f \u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u0443\u044e \u0444\u043e\u0440\u043c\u0443 \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u0435\u043c\u0443 \u043f\u0440\u043e\u043f\u0435\u0440\u0442\u0438 <strong>path<\/strong>. \u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 shapeLayer \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043c\u0430\u0441\u043a\u0438, \u0432\u0441\u0451, \u0447\u0442\u043e \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432\u043d\u0435 \u0444\u043e\u0440\u043c\u044b, \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c\u043e\u0439 shapeLayer.path, \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043a\u0430\u043a \u0444\u0438\u043b\u044c\u0442\u0440 \u0441 alpha = 0.<\/p>\n<p>\u0421\u0430\u043c\u0443 \u0444\u043e\u0440\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0434\u0430\u0442\u044c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f <strong>UIBezierPath<\/strong>: \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0443 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u0435\u0441\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438<br \/><strong>addLine(to:)<\/strong>, <strong>move(to:)<\/strong>, <strong>addArc(withCenter:radius:startAngle:endAngle:clockwise)<\/strong> \u0438 \u0442.\u0434.<br \/>\u0417\u0434\u0435\u0441\u044c \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c \u043f\u0430\u0440\u0443 \u043c\u043e\u043c\u0435\u043d\u0442\u043e\u0432. \u0418\u0442\u043e\u0433\u043e\u0432\u044b\u0439 path \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a, \u0431\u0443\u0434\u0442\u043e \u0435\u0433\u043e &#171;\u043d\u0430\u0440\u0438\u0441\u043e\u0432\u0430\u043b\u0438, \u043d\u0435 \u043e\u0442\u0440\u044b\u0432\u0430\u044f \u043a\u0430\u0440\u0430\u043d\u0434\u0430\u0448 \u043e\u0442 \u0431\u0443\u043c\u0430\u0433\u0438&#187;: \u0441\u0442\u0430\u0440\u0442\u0443\u0435\u043c \u0438\u0437 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u043d\u0430 \u0433\u0440\u0430\u043d\u0438\u0446\u0435 \u0438 \u043f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043b\u0438\u043d\u0438\u0438 \u043a \u043e\u0431\u0449\u0435\u043c\u0443 \u043f\u0443\u0442\u0438 \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043a\u043e\u043d\u0435\u0446 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u043b\u0438\u043d\u0438\u0438 \u0431\u044b\u043b \u043d\u0430\u0447\u0430\u043b\u043e\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u043b\u0438\u043d\u0438\u0438, \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435. \u0412 \u043a\u043e\u043d\u0446\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u0443\u044e \u0442\u043e\u0447\u043a\u0443. \u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u0431\u0438\u0432\u0430\u0435\u0442 \u0441 \u0442\u043e\u043b\u043a\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044f addArc, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0432 \u043d\u0435\u0439 \u0435\u0441\u0442\u044c \u0432\u0440\u043e\u0434\u0435 \u0438 startAngle \u0438 endAngle, \u0438 clockwise. \u0412\u043e\u0442 clockwise \u043a\u0430\u043a \u0440\u0430\u0437 \u0438 \u043d\u0443\u0436\u0435\u043d \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0442\u0435\u043c, \u0432\u0434\u043e\u043b\u044c \u043a\u0430\u043a\u043e\u0439 \u0438\u0437 \u0447\u0430\u0441\u0442\u0435\u0439 \u043e\u043a\u0440\u0443\u0436\u043d\u043e\u0441\u0442\u0438, \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0439 \u0434\u0432\u0443\u043c\u044f \u0443\u0433\u043b\u0430\u043c\u0438, \u043c\u044b \u0434\u0432\u0438\u0433\u0430\u0435\u043c\u0441\u044f. \u0412 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0432 \u043f\u0440\u0430\u0432\u043e\u043c \u0432\u0435\u0440\u0445\u043d\u0435\u043c \u0443\u0433\u043b\u0443 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u0443\u0441\u043e\u043a \u043e\u043a\u0440\u0443\u0436\u043d\u043e\u0441\u0442\u0438 \u043e\u0442 -\u03c0\/2 \u0434\u043e 0 \u0441 clockwise \u0440\u0430\u0432\u043d\u044b\u043c \u0438\u043c\u0435\u043d\u043d\u043e true, \u0438\u043d\u0430\u0447\u0435 \u043c\u044b \u0431\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0440\u0435\u0437\u0430\u043b\u0438 \u0446\u0435\u043b\u0443\u044e \u043e\u043a\u0440\u0443\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0437 \u043d\u0430\u0448\u0435\u0439 view:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/db4\/19a\/15d\/db419a15d28447b93ee3a9e32c54d076.png\" alt=\"\" title=\"\" width=\"597\" height=\"241\"><figcaption><\/figcaption><\/figure>\n<p>\u0410 \u0437\u0430\u0447\u0435\u043c \u0437\u0434\u0435\u0441\u044c \u0432\u043e\u043e\u0431\u0449\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0441\u043b\u043e\u0439? \u041f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u043d\u0435 \u0437\u0430\u0434\u0430\u0442\u044c \u043c\u0430\u0441\u043a\u0443 \u0443 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e?<br \/>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043c\u0430\u0441\u043a\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u0430\u043a, \u0447\u0442\u043e \u043e\u0442\u0440\u0435\u0437\u0430\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u0441\u0451, \u0447\u0442\u043e \u0435\u0439 \u043f\u043e\u043f\u0430\u0434\u0451\u0442\u0441\u044f, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0438 \u0442\u0435\u043d\u044c \u0441\u043b\u043e\u044f. \u0422\u0430\u043a \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c mask \u0443 \u0441\u043b\u043e\u044f \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0439 view, \u0442\u043e \u0442\u0435\u043d\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u0438\u0434\u043d\u043e.<\/p>\n<p>\u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438\u0434\u0430\u0442\u044c \u043d\u0443\u0436\u043d\u0443\u044e \u0444\u043e\u0440\u043c\u0443 \u0442\u0435\u043d\u0438, \u0443 CALayer \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <strong>shadowPath<\/strong>.<\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 1<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"swift\">import UIKit  final class SimpleCustomBorderAndShadowView: UIView {   private let frontLayer = CALayer()   private let inset: CGFloat = 40      \/\/ MARK: Override      override init(frame: CGRect) {     super.init(frame: frame)     setup()   }      required init?(coder: NSCoder) {     super.init(coder: coder)     setup()   }      override func layoutSubviews() {     super.layoutSubviews()     frontLayer.frame = bounds          let maskAndShadowPath = UIBezierPath()     maskAndShadowPath.move(to: CGPoint(x: 0, y: inset))     maskAndShadowPath.addLine(to: CGPoint(x: inset, y: 0))     maskAndShadowPath.addLine(to: CGPoint(x: bounds.width - inset, y: 0))     maskAndShadowPath.addArc(withCenter: CGPoint(x: bounds.width - inset, y: inset),                              radius: inset,                              startAngle: -CGFloat.pi \/ 2,                              endAngle: 0,                              clockwise: true)     maskAndShadowPath.addLine(to: CGPoint(x: bounds.width, y: bounds.height - inset))     maskAndShadowPath.addLine(to: CGPoint(x: bounds.width - inset, y: bounds.height))     maskAndShadowPath.addLine(to: CGPoint(x: inset, y: bounds.height))     maskAndShadowPath.addArc(withCenter: CGPoint(x: inset, y: bounds.height - inset),                              radius: inset,                              startAngle: CGFloat.pi \/ 2,                              endAngle: CGFloat.pi,                              clockwise: true)     maskAndShadowPath.close()          (frontLayer.mask as? CAShapeLayer)?.frame = bounds     (frontLayer.mask as? CAShapeLayer)?.path = maskAndShadowPath.cgPath     layer.shadowPath = maskAndShadowPath.cgPath    }      \/\/ MARK: Setup      private func setup() {     backgroundColor = .clear          layer.shadowColor = UIColor.black.cgColor     layer.shadowOffset = .zero     layer.shadowRadius = 20     layer.shadowOpacity = 1          frontLayer.mask = CAShapeLayer()     frontLayer.backgroundColor = UIColor.white.cgColor     layer.addSublayer(frontLayer)   } }<\/code><\/pre>\n<\/div>\n<\/details>\n<h2>\u041f\u0440\u0438\u043c\u0435\u0440 2: view \u0441 \u0432\u044b\u0440\u0435\u0437\u0430\u043d\u043d\u043e\u0439 \u043a\u0440\u0438\u0432\u043e\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u0438\u0434\u0430<\/h2>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/3d6\/248\/a22\/3d6248a226b6a16942a363ad41af4354.png\" width=\"2208\" height=\"1242\"><figcaption><\/figcaption><\/figure>\n<p>\u0414\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0432\u044b\u0431\u0440\u0430\u043d, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0432\u0430 \u043c\u043e\u043c\u0435\u043d\u0442\u0430: \u043a\u0430\u043a \u0432\u044b\u0440\u0435\u0437\u0430\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u043b\u043e\u044f \u0438 \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0443\u0442\u044c, \u043a\u0430\u043a \u0431\u044b \u043e\u0431\u0432\u043e\u0434\u044f\u0449\u0438\u0439 \u043a\u0440\u0438\u0432\u0443\u044e \u043b\u0438\u043d\u0438\u044e \u043d\u0430 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0438 \u043e\u0442 \u043d\u0435\u0451. <\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0432\u044b\u0440\u0435\u0437\u0430\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u043b\u043e\u044f, \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u043f\u043e \u043a\u0430\u043a\u043e\u043c\u0443 \u043f\u0440\u0430\u0432\u0438\u043b\u0443 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0440\u0430\u0441\u043a\u0440\u0430\u0448\u0438\u0432\u0430\u043d\u0438\u0435 \u0444\u043e\u0440\u043c, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e UIBezierPath. \u0412 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435, \u043f\u0440\u043e \u044d\u0442\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0432\u043d\u044f\u0442\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e <a href=\"https:\/\/developer.apple.com\/library\/archive\/documentation\/Cocoa\/Conceptual\/CocoaDrawingGuide\/Paths\/Paths.html#\/\/apple_ref\/doc\/uid\/TP40003290-CH206-BAJIJJGD\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u044d\u0444\u0444\u0435\u043a\u0442\u0430 \u043a\u0430\u043a \u043d\u0430 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0435 \u0432\u044b\u0448\u0435, \u043d\u0443\u0436\u043d\u043e \u0432 \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 path \u0434\u043b\u044f \u043c\u0430\u0441\u043a\u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u0443\u0442\u044c, \u043e\u0431\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u0432\u043d\u0435\u0448\u043d\u044e\u044e \u0433\u0440\u0430\u043d\u0438\u0446\u0443 view, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <strong>UIBezierPath(roundedRect:cornerRadius:)<\/strong>,<strong> <\/strong>\u0438 \u043f\u043e\u0441\u043b\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u0443\u0442\u044c, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0435\u0439 \u0432\u044b\u0440\u0435\u0437\u0443 \u0432 \u0444\u043e\u0440\u043c\u0435 \u043a\u0440\u0438\u0432\u043e\u0439. <a href=\"https:\/\/developer.apple.com\/library\/archive\/documentation\/Cocoa\/Conceptual\/CocoaDrawingGuide\/Paths\/Paths.html#\/\/apple_ref\/doc\/uid\/TP40003290-CH206-BAJIJJGD\" rel=\"noopener noreferrer nofollow\"><br \/><\/a><br \/>\u0414\u043b\u044f \u0444\u043e\u0440\u043c\u044b \u043a\u0440\u0438\u0432\u043e\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f <strong>addQuadCurve(to:controlPoint:)<\/strong>. \u0418 \u0435\u0441\u043b\u0438 \u0432\u0437\u044f\u0442\u044c UIBezierPath, \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c addQuadCurve, \u043f\u0440\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0435\u043c\u0443 \u0448\u0438\u0440\u0438\u043d\u0443 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <strong>lineWidth<\/strong>,<strong> <\/strong>\u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u044d\u0442\u043e \u0432 \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 path \u0434\u043b\u044f \u043c\u0430\u0441\u043a\u0438 \u0442\u043e&#8230; \u041d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0432\u044b\u0439\u0434\u0435\u0442. \u0415\u0441\u043b\u0438 \u0447\u0443\u0442\u044c-\u0447\u0443\u0442\u044c \u0437\u0430\u0434\u0443\u043c\u0430\u0442\u044c\u0441\u044f \u0438 \u0435\u0449\u0451 \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u0442\u044c \u043f\u0440\u043e <a href=\"https:\/\/developer.apple.com\/library\/archive\/documentation\/Cocoa\/Conceptual\/CocoaDrawingGuide\/Paths\/Paths.html#\/\/apple_ref\/doc\/uid\/TP40003290-CH206-BAJIJJGD\" rel=\"noopener noreferrer nofollow\">\u044d\u0442\u043e<\/a>, \u0442\u043e \u0432\u0441\u0451 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043b\u043e\u0433\u0438\u0447\u043d\u044b\u043c: CoreGraphics \u043d\u0443\u0436\u043d\u043e \u043a\u0430\u043a-\u0442\u043e \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043e \u0433\u0440\u0430\u043d\u0438\u0446\u0430\u0445, \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0435 \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e\u0434\u0441\u0447\u0451\u0442 \u043a\u0430\u043a\u0438\u0445-\u0442\u043e counter-\u043e\u0432 \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043e \u0442\u043e\u043c, \u043a\u0440\u0430\u0441\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u0443\u044e \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u0438\u043b\u0438 \u043d\u0435\u0442. \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043f\u0443\u0442\u044c \u0438\u043c\u0435\u043d\u043d\u043e \u0432\u043e\u043a\u0440\u0443\u0433 \u043a\u0440\u0438\u0432\u043e\u0439, \u0443 <strong>CGPath<\/strong> \u0435\u0441\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044f <strong>copy(strokingWithWidth:lineCap:lineJoin:miterLimit:)<\/strong>. \u0421\u0430\u043c<strong> <\/strong>CGPath, \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u0437 UIBezierPath, \u043e\u0431\u0440\u0430\u0449\u0430\u044f\u0441\u044c \u043a \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0443 <strong>cgPath<\/strong>.<\/p>\n<p>\u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043d\u0430\u0441\u0447\u0451\u0442 \u043a\u0440\u0438\u0432\u043e\u0439 \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0444\u043e\u0440\u043c\u044b, \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0435\u0439 \u0432\u044b\u0440\u0435\u0437\u0430\u0435\u043c\u0443\u044e \u043e\u0431\u043b\u0430\u0441\u0442\u044c, \u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0441\u043b\u0443\u043a\u0430\u0432\u0438\u043b, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043f\u0440\u0438 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u0438 \u0441\u0430\u043c\u043e\u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0439 \u0441 \u0443\u0447\u0451\u0442\u043e\u043c \u0448\u0438\u0440\u0438\u043d\u044b \u0431\u0443\u0434\u0443\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b.<\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 2<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"swift\">import UIKit  final class ErasedPathView: UIView {   private let frontLayer = CAShapeLayer()      \/\/ MARK: Override      override init(frame: CGRect) {     super.init(frame: frame)     setup()   }      required init?(coder: NSCoder) {     super.init(coder: coder)     setup()   }      override func layoutSubviews() {     super.layoutSubviews()          frontLayer.frame = bounds          let maskAndShadowPath = UIBezierPath(roundedRect: bounds, cornerRadius: 20)          let curvePath = UIBezierPath()     curvePath.move(to: CGPoint(x: bounds.width \/ 4, y: bounds.height \/ 4))     curvePath.addQuadCurve(to: CGPoint(x: bounds.width * 3 \/ 4, y: bounds.height * 3 \/ 4),                            controlPoint: CGPoint(x: bounds.width, y: 0))          let innerPath =  UIBezierPath(cgPath: curvePath.cgPath.copy(strokingWithWidth: 70, lineCap: .round, lineJoin: .round, miterLimit: 0))     maskAndShadowPath.append(innerPath)          (frontLayer.mask as? CAShapeLayer)?.frame = bounds     (frontLayer.mask as? CAShapeLayer)?.path = maskAndShadowPath.cgPath     layer.shadowPath = maskAndShadowPath.cgPath   }      \/\/ MARK: Setup      private func setup() {     backgroundColor = .clear     frontLayer.backgroundColor = UIColor.white.cgColor          layer.addSublayer(frontLayer)     let mask = CAShapeLayer()     mask.fillRule = .evenOdd     frontLayer.mask = mask          layer.shadowColor = UIColor.black.cgColor     layer.shadowOffset = .zero     layer.shadowRadius = 20     layer.shadowOpacity = 1   } }<\/code><\/pre>\n<\/div>\n<\/details>\n<h2>\u041f\u0440\u0438\u043c\u0435\u0440 3: \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u0435 \u0444\u043e\u0440\u043c \u0432\u043d\u0443\u0442\u0440\u0438 view<\/h2>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/7f3\/071\/4c8\/7f30714c8e15b3842dc57968c9205328.png\" width=\"2208\" height=\"1242\"><figcaption><\/figcaption><\/figure>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u0432\u043d\u0443\u0442\u0440\u0438 \u0432\u0430\u0448\u0435\u0439 view \u0432\u0441\u0451, \u0447\u0442\u043e \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f, \u0431\u0435\u0437 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0441\u043b\u043e\u0451\u0432, \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u044f\u0442\u044c \u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c CAShapeLayer. \u041d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c override \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 <strong>layerClass<\/strong> \u0443 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0439 view, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044f ShapeLayer.self, \u0438 \u0442\u0430\u043a \u0436\u0435 \u043a\u0430\u043a \u0438 \u0432 \u041f\u0440\u0438\u043c\u0435\u0440\u0435 1 \u0437\u0430\u0434\u0430\u0442\u044c \u044d\u0442\u043e\u043c\u0443 \u0441\u043b\u043e\u044e path.<\/p>\n<p>\u0415\u0441\u0442\u044c \u043e\u0434\u0438\u043d \u043d\u044e\u0430\u043d\u0441, \u043d\u0435 \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044b\u0439 \u0440\u0430\u043d\u0435\u0435. \u041f\u0440\u0438 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0438 \u043d\u0435\u043f\u0440\u0435\u0440\u044b\u0432\u043d\u043e\u0433\u043e \u043f\u0443\u0442\u0438 \u043f\u0440\u0438 \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0444\u043e\u0440\u043c\u044b \u043c\u043e\u0436\u043d\u043e \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u043f\u0435\u0440\u0435\u043f\u0440\u044b\u0433\u043d\u0443\u0442\u044c \u0438\u0437 \u043a\u043e\u043d\u0446\u0430 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u043b\u0438\u043d\u0438\u0438 \u0432 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u0434\u0440\u0443\u0433\u043e\u0435 \u043c\u0435\u0441\u0442\u043e. \u0422\u0438\u043f\u0438\u0447\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u2013 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u043a\u0443\u0441\u043a\u0430 \u043e\u043a\u0440\u0443\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0438 \u043d\u0435\u043f\u0443\u0441\u0442\u043e\u043c path. \u0412 \u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 CoreGraphics \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0430\u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043e\u0440\u0438\u0441\u0443\u0435\u0442 \u0437\u0430 \u0432\u0430\u0441 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u044e\u0449\u0443\u044e \u043b\u0438\u043d\u0438\u044e, \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u044e\u0449\u0443\u044e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u0442\u043e\u0447\u043a\u0443 \u043f\u0443\u0442\u0438 \u0438 \u043d\u043e\u0432\u0443\u044e \u0442\u043e\u0447\u043a\u0443 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c\u043e\u0439 \u043b\u0438\u043d\u0438\u0438. \u0412 \u0441\u043e\u0432\u043e\u043a\u0443\u043f\u043d\u043e\u0441\u0442\u0438 \u0441 <strong>fillRule <\/strong>\u0443 CAShapeLayer \u044d\u0442\u0438\u043c \u043c\u043e\u0436\u043d\u043e \u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0430 \u0442\u0440\u0435\u0442\u044c\u0435\u0439 \u0441\u043f\u0440\u0430\u0432\u0430 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0435 (\u043a\u0430\u0440\u0442\u0430 \u0442\u0440\u0435\u0444) \u044d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u0435: \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0434\u0443\u043c\u0430\u0442\u044c \u043e \u0442\u043e\u043c, \u0432 \u043a\u0430\u043a\u0438\u0445 \u0438\u043c\u0435\u043d\u043d\u043e \u043c\u0435\u0441\u0442\u0430\u0445 \u043f\u0435\u0440\u0435\u0441\u0435\u043a\u0430\u044e\u0442\u0441\u044f \u043e\u043a\u0440\u0443\u0436\u043d\u043e\u0441\u0442\u0438. <\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u0438\u043a\u0438<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"swift\">import UIKit  final class SpadeCardView: UIView {      var selfLayer: CAShapeLayer { layer as! CAShapeLayer }   private let inset: CGFloat = 20      \/\/ MARK: Override      static override var layerClass: AnyClass { CAShapeLayer.self }      override init(frame: CGRect) {     super.init(frame: frame)     setup()   }      required init?(coder: NSCoder) {     super.init(coder: coder)     setup()   }      override func layoutSubviews() {     super.layoutSubviews()          let path = UIBezierPath()     let size = bounds.width - 2 * inset     let radius = size \/ 4     let alpha = atan(2 * radius \/ size)          path.move(to: CGPoint(x: bounds.width \/ 2, y: bounds.height \/ 2))     path.addArc(withCenter: CGPoint(x: inset + radius, y: bounds.height \/ 2),                 radius: radius, startAngle: 0,                 endAngle: CGFloat.pi + 2 * alpha,                 clockwise: true)     path.addLine(to: CGPoint(x: bounds.width \/ 2, y: bounds.height \/ 2 - size \/ 2))     path.addArc(withCenter: CGPoint(x: bounds.width \/ 2 + radius, y: bounds.height \/ 2),                 radius: radius,                 startAngle: -2 * alpha,                 endAngle: CGFloat.pi,                 clockwise: true)     path.addQuadCurve(to: CGPoint(x: bounds.width \/ 2 + radius, y: bounds.height \/ 2 + size \/ 2),                       controlPoint: CGPoint(x: bounds.width \/ 2, y: bounds.height \/ 2 + size \/ 2))     path.addLine(to: CGPoint(x: bounds.width \/ 2 - radius, y: bounds.height \/ 2 + size \/ 2))     path.addQuadCurve(to: CGPoint(x: bounds.width \/ 2, y: bounds.height \/ 2),                       controlPoint: CGPoint(x: bounds.width \/ 2, y: bounds.height \/ 2 + size \/ 2))          selfLayer.path = path.cgPath   }      \/\/ MARK: Setup      private func setup() {     selfLayer.fillColor = UIColor.black.cgColor     selfLayer.strokeColor = UIColor.black.cgColor     selfLayer.lineWidth = 2          layer.shadowColor = UIColor.black.cgColor     layer.shadowOffset = .zero     layer.shadowRadius = 10     layer.shadowOpacity = 1   } }<\/code><\/pre>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>\u0411\u0443\u0431\u043d\u044b<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"swift\">import UIKit  final class DiamondCardView: UIView {      var selfLayer: CAShapeLayer { layer as! CAShapeLayer }   private let inset: CGFloat = 20   private let adjustment: CGFloat = 10      \/\/ MARK: Override      static override var layerClass: AnyClass { CAShapeLayer.self }      override init(frame: CGRect) {     super.init(frame: frame)     setup()   }      required init?(coder: NSCoder) {     super.init(coder: coder)     setup()   }      override func layoutSubviews() {     super.layoutSubviews()          let path = UIBezierPath()     let size = bounds.width - 2 * inset          path.move(to: CGPoint(x: inset, y: bounds.height \/ 2))     path.addQuadCurve(to: CGPoint(x: bounds.width \/ 2, y: bounds.height \/ 2 - size \/ 2),                       controlPoint: CGPoint(x: bounds.width \/ 2 - adjustment, y: bounds.height \/ 2 - adjustment))     path.addQuadCurve(to: CGPoint(x: bounds.width - inset, y: bounds.height \/ 2),                       controlPoint: CGPoint(x: bounds.width \/ 2 + adjustment, y: bounds.height \/ 2 - adjustment))     path.addQuadCurve(to: CGPoint(x: bounds.width \/ 2, y: bounds.height \/ 2 + size \/ 2),                       controlPoint: CGPoint(x: bounds.width \/ 2 + adjustment, y: bounds.height \/ 2 + adjustment))     path.addQuadCurve(to: CGPoint(x: inset, y: bounds.height \/ 2),                       controlPoint: CGPoint(x: bounds.width \/ 2 - adjustment, y: bounds.height \/ 2 + adjustment))          selfLayer.path = path.cgPath   }      \/\/ MARK: Setup      private func setup() {     selfLayer.fillColor = UIColor.red.cgColor     selfLayer.strokeColor = UIColor.red.cgColor     selfLayer.lineWidth = 2          layer.shadowColor = UIColor.black.cgColor     layer.shadowOffset = .zero     layer.shadowRadius = 20     layer.shadowOpacity = 1   } }<\/code><\/pre>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>\u0422\u0440\u0435\u0444\u044b<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"swift\">import UIKit  final class ClubCardView: UIView {      var selfLayer: CAShapeLayer { layer as! CAShapeLayer }   private let inset: CGFloat = 20   private let adjustment: CGFloat = 10      \/\/ MARK: Override      static override var layerClass: AnyClass { CAShapeLayer.self }      override init(frame: CGRect) {     super.init(frame: frame)     setup()   }      required init?(coder: NSCoder) {     super.init(coder: coder)     setup()   }      override func layoutSubviews() {     super.layoutSubviews()          let path = UIBezierPath()     let size = bounds.width - 2 * inset     let radius = size \/ 4          path.move(to: CGPoint(x: bounds.width \/ 2, y: bounds.height \/ 2))     path.addArc(withCenter: CGPoint(x: bounds.width \/ 2 - radius, y: bounds.height \/ 2 + adjustment),                 radius: radius,                 startAngle: 0,                 endAngle: 2 * CGFloat.pi,                 clockwise: true)     path.addArc(withCenter: CGPoint(x: bounds.width \/ 2, y: bounds.height \/ 2 - radius),                 radius: radius,                 startAngle: CGFloat.pi \/ 2,                 endAngle: 5 * CGFloat.pi \/ 2,                 clockwise: true)     path.addArc(withCenter: CGPoint(x: bounds.width \/ 2 + radius, y: bounds.height \/ 2 + adjustment),                 radius: radius,                 startAngle: CGFloat.pi,                 endAngle: 3 * CGFloat.pi,                 clockwise: true)     path.addQuadCurve(to: CGPoint(x: bounds.width \/ 2 + radius, y: bounds.height \/ 2 + size \/ 2),                       controlPoint: CGPoint(x: bounds.width \/ 2, y: bounds.height \/ 2 + size \/ 2))     path.addLine(to: CGPoint(x: bounds.width \/ 2 - radius, y: bounds.height \/ 2 + size \/ 2))     path.addQuadCurve(to: CGPoint(x: bounds.width \/ 2, y: bounds.height \/ 2),                       controlPoint: CGPoint(x: bounds.width \/ 2, y: bounds.height \/ 2 + size \/ 2))          selfLayer.path = path.cgPath   }      \/\/ MARK: Setup      private func setup() {     selfLayer.fillColor = UIColor.black.cgColor     selfLayer.strokeColor = UIColor.black.cgColor     selfLayer.fillRule = .nonZero     selfLayer.lineWidth = 2          layer.shadowColor = UIColor.black.cgColor     layer.shadowOffset = .zero     layer.shadowRadius = 20     layer.shadowOpacity = 1   } }<\/code><\/pre>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>\u0427\u0435\u0440\u0432\u0438<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"swift\">import UIKit  final class HeartCardView: UIView {      var selfLayer: CAShapeLayer { layer as! CAShapeLayer }   private let inset: CGFloat = 20      \/\/ MARK: Override      static override var layerClass: AnyClass { CAShapeLayer.self }      override init(frame: CGRect) {     super.init(frame: frame)     setup()   }      required init?(coder: NSCoder) {     super.init(coder: coder)     setup()   }      override func layoutSubviews() {     super.layoutSubviews()          let path = UIBezierPath()     let size = bounds.width - 2 * inset     let radius = size \/ 4     let alpha = atan(4 * radius \/ (3 * size))          path.move(to: CGPoint(x: bounds.width \/ 2, y: bounds.height \/ 2 + size \/ 2))     path.addArc(withCenter: CGPoint(x: inset + radius, y: bounds.height \/ 2 - radius),                 radius: radius,                 startAngle: CGFloat.pi - 2 * alpha,                 endAngle: 0,                 clockwise: true)     path.addArc(withCenter: CGPoint(x: bounds.width \/ 2 + radius, y: bounds.height \/ 2 - radius),                 radius: radius,                 startAngle: -CGFloat.pi,                 endAngle: 2 * alpha,                 clockwise: true)     path.addLine(to: CGPoint(x: bounds.width \/ 2, y: bounds.height \/ 2 + size \/ 2))          selfLayer.path = path.cgPath   }      \/\/ MARK: Setup      private func setup() {     selfLayer.fillColor = UIColor.red.cgColor     selfLayer.strokeColor = UIColor.red.cgColor          layer.shadowColor = UIColor.black.cgColor     layer.shadowOffset = .zero     layer.shadowRadius = 20     layer.shadowOpacity = 1   } }<\/code><\/pre>\n<\/div>\n<\/details>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u041d\u0438\u0436\u0435, \u0442\u0430\u043a \u0441\u043a\u0430\u0437\u0430\u0442\u044c, things to remember:<\/p>\n<ul>\n<li>\n<p><strong>+1 CALayer, mask, CAShapeLayer, shadowPath<\/strong> \u2013 \u0434\u043b\u044f \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u043e\u0439 \u0433\u0440\u0430\u043d\u0438\u0446\u044b \u0438 \u0442\u0435\u043d\u0438<\/p>\n<\/li>\n<li>\n<p><strong>copy(strokingWithWidth:lineCap:lineJoin:miterLimit:)<\/strong> \u2013<strong> <\/strong>\u0434\u043b\u044f \u043e\u0431\u044a\u0435\u043c\u043d\u043e\u0439 \u043e\u0431\u0432\u043e\u0434\u043a\u0438 path<\/p>\n<\/li>\n<li>\n<p><strong>CAShapeLayer, path + fillRule <\/strong>\u2013<strong> <\/strong>\u0434\u0430\u0451\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438<\/p>\n<\/li>\n<\/ul>\n<p>\u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043d\u0430 \u044d\u0442\u0443 \u0442\u0435\u043c\u0443 \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0440\u043e layout-\u044b \u0432 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f\u0445. \u0412\u0441\u0435\u043c \u0434\u043e\u0431\u0440\u0430, \u043f\u0438\u0448\u0438\u0442\u0435 \u043a\u043b\u0430\u0441\u0441\u043d\u044b\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u0434\u0435\u043b\u0430\u0439\u0442\u0435 \u043a\u0440\u0430\u0441\u043e\u0442\u0443 \u0432 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430\u0445!<\/p>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/549300\/\"> https:\/\/habr.com\/ru\/post\/549300\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044f\u043c \u0425\u0430\u0431\u0440\u0430!<\/p>\n<p>\u042f iOS-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a, \u0438 \u0442\u0430\u043a \u0441\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u043c\u043d\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u043c\u043d\u043e\u0433\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0432 ui: \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0435 view, \u0442\u0435\u043d\u0438, layout-\u044b, \u043a\u043d\u043e\u043f\u043a\u0438 \u0438 \u0432\u043e\u0442 \u044d\u0442\u043e \u0432\u0441\u0451. \u0412 \u044d\u0442\u043e\u0439 \u0438 \u043f\u0430\u0440\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0441\u0442\u0430\u0442\u0435\u0439 \u0445\u043e\u0447\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043f\u0440\u0438\u0451\u043c\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043c\u043e\u0433\u0430\u043b\u0438 \u043c\u043d\u0435 \u0434\u043e\u0431\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0432\u0435\u0441\u044c\u043c\u0430 \u043a\u0440\u0430\u0441\u0438\u0432\u044b\u0445 \u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0445 \u044d\u0444\u0444\u0435\u043a\u0442\u043e\u0432 \u0432 \u043f\u043b\u0430\u043d\u0435 \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 ui. \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u043a\u043e\u043c\u0443-\u043d\u0438\u0431\u0443\u0434\u044c \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u043e. \u041d\u0443 \u0438\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e.<\/p>\n<h2>\u041d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0432\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h2>\n<p>\u041d\u0435 \u0431\u0435\u0440\u0443\u0441\u044c \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u0437\u0430 \u0432\u0441\u0435\u0445, \u043d\u043e, \u0438\u0441\u0445\u043e\u0434\u044f \u0438\u0437 \u043b\u0438\u0447\u043d\u043e\u0433\u043e \u043e\u043f\u044b\u0442\u0430, \u0441\u043b\u043e\u0436\u0438\u043b\u043e\u0441\u044c \u0432\u043f\u0435\u0447\u0430\u0442\u043b\u0435\u043d\u0438\u0435, \u0447\u0442\u043e \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u0430\u043a\u0438\u0445-\u0442\u043e &#171;\u043f\u043b\u0430\u0448\u0435\u043a&#187; \u0441 \u043d\u0435\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u043c\u0438 \u0444\u043e\u0440\u043c\u043e\u0439 \u0438 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435\u043c \u2013 \u043a\u0440\u0430\u0439\u043d\u0435 \u043d\u0435\u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430. \u041a\u0442\u043e-\u0442\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u0432 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0435, \u043a\u0442\u043e-\u0442\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u0440\u043e &#171;\u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0431\u0438\u0437\u043d\u0435\u0441\u0443 \u0445\u043e\u0440\u043e\u0448\u043e&#187; \u0441 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0443\u0441\u0438\u043b\u0438\u044f\u043c\u0438 (\u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043f\u0440\u043e\u0441\u044f\u0442 \u043f\u043e\u0443\u043c\u0435\u0440\u0438\u0442\u044c \u043f\u044b\u043b \u0434\u0438\u0437\u0430\u0439\u043d\u0435\u0440\u043e\u0432) \u0438 \u0442.\u043f. \u0418 \u0435\u0441\u043b\u0438 \u0443\u0436 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0434\u0435\u043b\u0430\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0438\u0437 \u0440\u044f\u0434\u0430 \u0432\u043e\u043d, \u0442\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f google, stackoverflow, \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u044b \u0438 \u0442.\u0434., \u0447\u0442\u043e \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u043d\u0435\u043c\u0430\u043b\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u0438 \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0449\u0443\u0449\u0435\u043d\u0438\u0435, \u0447\u0442\u043e \u043e\u043d\u043e \u0442\u043e\u0433\u043e \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435 \u0441\u0442\u043e\u0438\u0442. \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u044d\u0442\u0443 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0441\u0435\u0440\u0438\u044e \u0441\u0442\u0430\u0442\u0435\u0439 \u044f \u0438 \u0437\u0430\u0434\u0443\u043c\u0430\u043b \u043a\u0430\u043a \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0441\u043f\u0440\u0430\u0432\u043a\u0443, \u043f\u0440\u043e\u0447\u0442\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0441\u043d\u0438\u043c\u0435\u0442 \u0440\u044f\u0434 \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432 \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u043e\u0446\u0435\u043d\u0438\u0432\u0430\u0442\u044c\/\u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u043d\u0435\u0442\u0438\u043f\u0438\u0447\u043d\u044b\u0435 ui-\u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b. \u041d\u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u043a\u0430\u043a, \u0447\u0442\u043e \u0438 \u043f\u043e\u0447\u0435\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c.<\/p>\n<h2>\u041f\u0440\u0438\u043c\u0435\u0440 1: view \u0441 \u043d\u0435\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u043c\u0438 \u0433\u0440\u0430\u043d\u0438\u0446\u0435\u0439 \u0438 \u0442\u0435\u043d\u044c\u044e<\/h2>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u0434\u0435\u044f \u043f\u0440\u043e\u0441\u0442\u0430\u044f: \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0435\u0449\u0451 \u043e\u0434\u0438\u043d \u0441\u043b\u043e\u0439 \u0432 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u044e \u0441\u043b\u043e\u0451\u0432 \u043d\u0430\u0448\u0435\u0439 view, \u043f\u043e\u0440\u0435\u0437\u0430\u0442\u044c \u0433\u0440\u0430\u043d\u0438\u0446\u044b \u0443 \u044d\u0442\u043e\u0433\u043e \u0441\u043b\u043e\u044f, \u0430 \u0444\u043e\u0440\u043c\u0443 \u0442\u0435\u043d\u0438 (\u0443\u0436\u0435 \u0443 \u0441\u0430\u043c\u043e\u0439 view) \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0440\u043e\u0432\u043d\u043e \u0442\u0430\u043a\u043e\u0439 \u0436\u0435, \u043a\u0430\u043a \u0438 \u0444\u043e\u0440\u043c\u0430 \u0433\u0440\u0430\u043d\u0438\u0446\u044b \u0441\u043b\u043e\u044f.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0447\u0443\u0442\u044c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435. \u0423 CALayer \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <strong>mask<\/strong>.<strong> <\/strong>\u0412 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u043e \u0442\u043e\u0442 \u0436\u0435 \u0441\u0430\u043c\u044b\u0439 \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 CALayer, \u0438 \u0435\u0441\u043b\u0438 \u043e\u043d \u043d\u0435 nil, \u0442\u043e \u0435\u0433\u043e \u0430\u043b\u044c\u0444\u0430-\u043a\u0430\u043d\u0430\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u043c\u0430\u0441\u043a\u0430 \u0434\u043b\u044f \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e layer. \u0422\u043e \u0435\u0441\u0442\u044c \u0435\u0441\u043b\u0438 \u0432\u0437\u044f\u0442\u044c png-\u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443 \u0441 \u043a\u043e\u0442\u043e\u043c \u0438 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u044c\u044e \u0438 \u043a\u0430\u043a\u0438\u043c-\u0442\u043e \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0437\u0430\u0441\u0443\u043d\u0443\u0442\u044c \u0435\u0435 \u0432 CALayer (\u043d\u0430\u0437\u043e\u0432\u0435\u043c \u0435\u0433\u043e catLayer), \u0442\u043e \u043f\u0440\u0438 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u043d\u0438\u0438<strong> layer.mask = catLayer<\/strong> \u043a\u043e\u043d\u0442\u0435\u043d\u0442 \u043d\u0430\u0448\u0435\u0433\u043e \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e layer \u0431\u0443\u0434\u0435\u0442 \u0432 \u0432\u0438\u0434\u0435 \u043a\u043e\u0442\u0430, \u0447\u0442\u043e \u0431\u044b \u043d\u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u0443 \u043d\u0435\u0433\u043e \u0432\u043d\u0443\u0442\u0440\u0438. \u041c\u043e\u0436\u0435\u0442, \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0439 \u043a\u043e\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f, \u0435\u0441\u043b\u0438 \u0432\u043d\u0443\u0442\u0440\u0438 layer \u043c\u043d\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0430. \u0412 \u043d\u0430\u0448\u0435\u043c \u0436\u0435 \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0443\u0436\u0435\u043d layer-\u043c\u0430\u0441\u043a\u0430 \u0432 \u0432\u0438\u0434\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0444\u0438\u0433\u0443\u0440\u044b. \u0422\u0443\u0442 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043c\u043e\u0447\u044c <strong>CAShapeLayer<\/strong> &#8212; \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a CALayer, \u043a\u043e\u0442\u043e\u0440\u044b\u0439, \u0433\u0440\u0443\u0431\u043e \u0433\u043e\u0432\u043e\u0440\u044f, \u0443\u043c\u0435\u0435\u0442 \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u0435\u0431\u044f \u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u0443\u044e \u0444\u043e\u0440\u043c\u0443 \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u0435\u043c\u0443 \u043f\u0440\u043e\u043f\u0435\u0440\u0442\u0438 <strong>path<\/strong>. \u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 shapeLayer \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043c\u0430\u0441\u043a\u0438, \u0432\u0441\u0451, \u0447\u0442\u043e \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432\u043d\u0435 \u0444\u043e\u0440\u043c\u044b, \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c\u043e\u0439 shapeLayer.path, \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043a\u0430\u043a \u0444\u0438\u043b\u044c\u0442\u0440 \u0441 alpha = 0.<\/p>\n<p>\u0421\u0430\u043c\u0443 \u0444\u043e\u0440\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0434\u0430\u0442\u044c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f <strong>UIBezierPath<\/strong>: \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0443 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u0435\u0441\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438<br \/><strong>addLine(to:)<\/strong>, <strong>move(to:)<\/strong>, <strong>addArc(withCenter:radius:startAngle:endAngle:clockwise)<\/strong> \u0438 \u0442.\u0434.<br \/>\u0417\u0434\u0435\u0441\u044c \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c \u043f\u0430\u0440\u0443 \u043c\u043e\u043c\u0435\u043d\u0442\u043e\u0432. \u0418\u0442\u043e\u0433\u043e\u0432\u044b\u0439 path \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a, \u0431\u0443\u0434\u0442\u043e \u0435\u0433\u043e &#171;\u043d\u0430\u0440\u0438\u0441\u043e\u0432\u0430\u043b\u0438, \u043d\u0435 \u043e\u0442\u0440\u044b\u0432\u0430\u044f \u043a\u0430\u0440\u0430\u043d\u0434\u0430\u0448 \u043e\u0442 \u0431\u0443\u043c\u0430\u0433\u0438&#187;: \u0441\u0442\u0430\u0440\u0442\u0443\u0435\u043c \u0438\u0437 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u043d\u0430 \u0433\u0440\u0430\u043d\u0438\u0446\u0435 \u0438 \u043f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043b\u0438\u043d\u0438\u0438 \u043a \u043e\u0431\u0449\u0435\u043c\u0443 \u043f\u0443\u0442\u0438 \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043a\u043e\u043d\u0435\u0446 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u043b\u0438\u043d\u0438\u0438 \u0431\u044b\u043b \u043d\u0430\u0447\u0430\u043b\u043e\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u043b\u0438\u043d\u0438\u0438, \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435. \u0412 \u043a\u043e\u043d\u0446\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u0443\u044e \u0442\u043e\u0447\u043a\u0443. \u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u0431\u0438\u0432\u0430\u0435\u0442 \u0441 \u0442\u043e\u043b\u043a\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044f addArc, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0432 \u043d\u0435\u0439 \u0435\u0441\u0442\u044c \u0432\u0440\u043e\u0434\u0435 \u0438 startAngle \u0438 endAngle, \u0438 clockwise. \u0412\u043e\u0442 clockwise \u043a\u0430\u043a \u0440\u0430\u0437 \u0438 \u043d\u0443\u0436\u0435\u043d \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0442\u0435\u043c, \u0432\u0434\u043e\u043b\u044c \u043a\u0430\u043a\u043e\u0439 \u0438\u0437 \u0447\u0430\u0441\u0442\u0435\u0439 \u043e\u043a\u0440\u0443\u0436\u043d\u043e\u0441\u0442\u0438, \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0439 \u0434\u0432\u0443\u043c\u044f \u0443\u0433\u043b\u0430\u043c\u0438, \u043c\u044b \u0434\u0432\u0438\u0433\u0430\u0435\u043c\u0441\u044f. \u0412 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0432 \u043f\u0440\u0430\u0432\u043e\u043c \u0432\u0435\u0440\u0445\u043d\u0435\u043c \u0443\u0433\u043b\u0443 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u0443\u0441\u043e\u043a \u043e\u043a\u0440\u0443\u0436\u043d\u043e\u0441\u0442\u0438 \u043e\u0442 -\u03c0\/2 \u0434\u043e 0 \u0441 clockwise \u0440\u0430\u0432\u043d\u044b\u043c \u0438\u043c\u0435\u043d\u043d\u043e true, \u0438\u043d\u0430\u0447\u0435 \u043c\u044b \u0431\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0440\u0435\u0437\u0430\u043b\u0438 \u0446\u0435\u043b\u0443\u044e \u043e\u043a\u0440\u0443\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0437 \u043d\u0430\u0448\u0435\u0439 view:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0410 \u0437\u0430\u0447\u0435\u043c \u0437\u0434\u0435\u0441\u044c \u0432\u043e\u043e\u0431\u0449\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0441\u043b\u043e\u0439? \u041f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u043d\u0435 \u0437\u0430\u0434\u0430\u0442\u044c \u043c\u0430\u0441\u043a\u0443 \u0443 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e?<br \/>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043c\u0430\u0441\u043a\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u0430\u043a, \u0447\u0442\u043e \u043e\u0442\u0440\u0435\u0437\u0430\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u0441\u0451, \u0447\u0442\u043e \u0435\u0439 \u043f\u043e\u043f\u0430\u0434\u0451\u0442\u0441\u044f, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0438 \u0442\u0435\u043d\u044c \u0441\u043b\u043e\u044f. \u0422\u0430\u043a \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c mask \u0443 \u0441\u043b\u043e\u044f \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0439 view, \u0442\u043e \u0442\u0435\u043d\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u0438\u0434\u043d\u043e.<\/p>\n<p>\u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438\u0434\u0430\u0442\u044c \u043d\u0443\u0436\u043d\u0443\u044e \u0444\u043e\u0440\u043c\u0443 \u0442\u0435\u043d\u0438, \u0443 CALayer \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <strong>shadowPath<\/strong>.<\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 1<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"swift\">import UIKit  final class SimpleCustomBorderAndShadowView: UIView {   private let frontLayer = CALayer()   private let inset: CGFloat = 40      \/\/ MARK: Override      override init(frame: CGRect) {     super.init(frame: frame)     setup()   }      required init?(coder: NSCoder) {     super.init(coder: coder)     setup()   }      override func layoutSubviews() {     super.layoutSubviews()     frontLayer.frame = bounds          let maskAndShadowPath = UIBezierPath()     maskAndShadowPath.move(to: CGPoint(x: 0, y: inset))     maskAndShadowPath.addLine(to: CGPoint(x: inset, y: 0))     maskAndShadowPath.addLine(to: CGPoint(x: bounds.width - inset, y: 0))     maskAndShadowPath.addArc(withCenter: CGPoint(x: bounds.width - inset, y: inset),                              radius: inset,                              startAngle: -CGFloat.pi \/ 2,                              endAngle: 0,                              clockwise: true)     maskAndShadowPath.addLine(to: CGPoint(x: bounds.width, y: bounds.height - inset))     maskAndShadowPath.addLine(to: CGPoint(x: bounds.width - inset, y: bounds.height))     maskAndShadowPath.addLine(to: CGPoint(x: inset, y: bounds.height))     maskAndShadowPath.addArc(withCenter: CGPoint(x: inset, y: bounds.height - inset),                              radius: inset,                              startAngle: CGFloat.pi \/ 2,                              endAngle: CGFloat.pi,                              clockwise: true)     maskAndShadowPath.close()          (frontLayer.mask as? CAShapeLayer)?.frame = bounds     (frontLayer.mask as? CAShapeLayer)?.path = maskAndShadowPath.cgPath     layer.shadowPath = maskAndShadowPath.cgPath    }      \/\/ MARK: Setup      private func setup() {     backgroundColor = .clear          layer.shadowColor = UIColor.black.cgColor     layer.shadowOffset = .zero     layer.shadowRadius = 20     layer.shadowOpacity = 1          frontLayer.mask = CAShapeLayer()     frontLayer.backgroundColor = UIColor.white.cgColor     layer.addSublayer(frontLayer)   } }<\/code><\/pre>\n<\/div>\n<\/details>\n<h2>\u041f\u0440\u0438\u043c\u0435\u0440 2: view \u0441 \u0432\u044b\u0440\u0435\u0437\u0430\u043d\u043d\u043e\u0439 \u043a\u0440\u0438\u0432\u043e\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u0438\u0434\u0430<\/h2>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0414\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0432\u044b\u0431\u0440\u0430\u043d, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0432\u0430 \u043c\u043e\u043c\u0435\u043d\u0442\u0430: \u043a\u0430\u043a \u0432\u044b\u0440\u0435\u0437\u0430\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u043b\u043e\u044f \u0438 \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0443\u0442\u044c, \u043a\u0430\u043a \u0431\u044b \u043e\u0431\u0432\u043e\u0434\u044f\u0449\u0438\u0439 \u043a\u0440\u0438\u0432\u0443\u044e \u043b\u0438\u043d\u0438\u044e \u043d\u0430 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0438 \u043e\u0442 \u043d\u0435\u0451. <\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0432\u044b\u0440\u0435\u0437\u0430\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u043b\u043e\u044f, \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u043f\u043e \u043a\u0430\u043a\u043e\u043c\u0443 \u043f\u0440\u0430\u0432\u0438\u043b\u0443 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0440\u0430\u0441\u043a\u0440\u0430\u0448\u0438\u0432\u0430\u043d\u0438\u0435 \u0444\u043e\u0440\u043c, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e UIBezierPath. \u0412 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435, \u043f\u0440\u043e \u044d\u0442\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0432\u043d\u044f\u0442\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e <a href=\"https:\/\/developer.apple.com\/library\/archive\/documentation\/Cocoa\/Conceptual\/CocoaDrawingGuide\/Paths\/Paths.html#\/\/apple_ref\/doc\/uid\/TP40003290-CH206-BAJIJJGD\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u044d\u0444\u0444\u0435\u043a\u0442\u0430 \u043a\u0430\u043a \u043d\u0430 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0435 \u0432\u044b\u0448\u0435, \u043d\u0443\u0436\u043d\u043e \u0432 \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 path \u0434\u043b\u044f \u043c\u0430\u0441\u043a\u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u0443\u0442\u044c, \u043e\u0431\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u0432\u043d\u0435\u0448\u043d\u044e\u044e \u0433\u0440\u0430\u043d\u0438\u0446\u0443 view, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <strong>UIBezierPath(roundedRect:cornerRadius:)<\/strong>,<strong> <\/strong>\u0438 \u043f\u043e\u0441\u043b\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u0443\u0442\u044c, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0435\u0439 \u0432\u044b\u0440\u0435\u0437\u0443 \u0432 \u0444\u043e\u0440\u043c\u0435 \u043a\u0440\u0438\u0432\u043e\u0439. <a href=\"https:\/\/developer.apple.com\/library\/archive\/documentation\/Cocoa\/Conceptual\/CocoaDrawingGuide\/Paths\/Paths.html#\/\/apple_ref\/doc\/uid\/TP40003290-CH206-BAJIJJGD\" rel=\"noopener noreferrer nofollow\"><br \/><\/a><br \/>\u0414\u043b\u044f \u0444\u043e\u0440\u043c\u044b \u043a\u0440\u0438\u0432\u043e\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f <strong>addQuadCurve(to:controlPoint:)<\/strong>. \u0418 \u0435\u0441\u043b\u0438 \u0432\u0437\u044f\u0442\u044c UIBezierPath, \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c addQuadCurve, \u043f\u0440\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0435\u043c\u0443 \u0448\u0438\u0440\u0438\u043d\u0443 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <strong>lineWidth<\/strong>,<strong> <\/strong>\u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u044d\u0442\u043e \u0432 \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 path \u0434\u043b\u044f \u043c\u0430\u0441\u043a\u0438 \u0442\u043e&#8230; \u041d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0432\u044b\u0439\u0434\u0435\u0442. \u0415\u0441\u043b\u0438 \u0447\u0443\u0442\u044c-\u0447\u0443\u0442\u044c \u0437\u0430\u0434\u0443\u043c\u0430\u0442\u044c\u0441\u044f \u0438 \u0435\u0449\u0451 \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u0442\u044c \u043f\u0440\u043e <a href=\"https:\/\/developer.apple.com\/library\/archive\/documentation\/Cocoa\/Conceptual\/CocoaDrawingGuide\/Paths\/Paths.html#\/\/apple_ref\/doc\/uid\/TP40003290-CH206-BAJIJJGD\" rel=\"noopener noreferrer nofollow\">\u044d\u0442\u043e<\/a>, \u0442\u043e \u0432\u0441\u0451 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043b\u043e\u0433\u0438\u0447\u043d\u044b\u043c: CoreGraphics \u043d\u0443\u0436\u043d\u043e \u043a\u0430\u043a-\u0442\u043e \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043e \u0433\u0440\u0430\u043d\u0438\u0446\u0430\u0445, \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0435 \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e\u0434\u0441\u0447\u0451\u0442 \u043a\u0430\u043a\u0438\u0445-\u0442\u043e counter-\u043e\u0432 \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043e \u0442\u043e\u043c, \u043a\u0440\u0430\u0441\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u0443\u044e \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u0438\u043b\u0438 \u043d\u0435\u0442. \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043f\u0443\u0442\u044c \u0438\u043c\u0435\u043d\u043d\u043e \u0432\u043e\u043a\u0440\u0443\u0433 \u043a\u0440\u0438\u0432\u043e\u0439, \u0443 <strong>CGPath<\/strong> \u0435\u0441\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044f <strong>copy(strokingWithWidth:lineCap:lineJoin:miterLimit:)<\/strong>. \u0421\u0430\u043c<strong> <\/strong>CGPath, \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u0437 UIBezierPath, \u043e\u0431\u0440\u0430\u0449\u0430\u044f\u0441\u044c \u043a \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0443 <strong>cgPath<\/strong>.<\/p>\n<p>\u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043d\u0430\u0441\u0447\u0451\u0442 \u043a\u0440\u0438\u0432\u043e\u0439 \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0444\u043e\u0440\u043c\u044b, \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0435\u0439 \u0432\u044b\u0440\u0435\u0437\u0430\u0435\u043c\u0443\u044e \u043e\u0431\u043b\u0430\u0441\u0442\u044c, \u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0441\u043b\u0443\u043a\u0430\u0432\u0438\u043b, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043f\u0440\u0438 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u0438 \u0441\u0430\u043c\u043e\u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0439 \u0441 \u0443\u0447\u0451\u0442\u043e\u043c \u0448\u0438\u0440\u0438\u043d\u044b \u0431\u0443\u0434\u0443\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b.<\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 2<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"swift\">import UIKit  final class ErasedPathView: UIView {   private let frontLayer = CAShapeLayer()      \/\/ MARK: Override      override init(frame: CGRect) {     super.init(frame: frame)     setup()   }      required init?(coder: NSCoder) {     super.init(coder: coder)     setup()   }      override func layoutSubviews() {     super.layoutSubviews()          frontLayer.frame = bounds          let maskAndShadowPath = UIBezierPath(roundedRect: bounds, cornerRadius: 20)          let curvePath = UIBezierPath()     curvePath.move(to: CGPoint(x: bounds.width \/ 4, y: bounds.height \/ 4))     curvePath.addQuadCurve(to: CGPoint(x: bounds.width * 3 \/ 4, y: bounds.height * 3 \/ 4),                            controlPoint: CGPoint(x: bounds.width, y: 0))          let innerPath =  UIBezierPath(cgPath: curvePath.cgPath.copy(strokingWithWidth: 70, lineCap: .round, lineJoin: .round, miterLimit: 0))     maskAndShadowPath.append(innerPath)          (frontLayer.mask as? CAShapeLayer)?.frame = bounds     (frontLayer.mask as? CAShapeLayer)?.path = maskAndShadowPath.cgPath     layer.shadowPath = maskAndShadowPath.cgPath   }      \/\/ MARK: Setup      private func setup() {     backgroundColor = .clear     frontLayer.backgroundColor = UIColor.white.cgColor          layer.addSublayer(frontLayer)     let mask = CAShapeLayer()     mask.fillRule = .evenOdd     frontLayer.mask = mask          layer.shadowColor = UIColor.black.cgColor     layer.shadowOffset = .zero     layer.shadowRadius = 20     layer.shadowOpacity = 1   } }<\/code><\/pre>\n<\/div>\n<\/details>\n<h2>\u041f\u0440\u0438\u043c\u0435\u0440 3: \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u0435 \u0444\u043e\u0440\u043c \u0432\u043d\u0443\u0442\u0440\u0438 view<\/h2>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u0432\u043d\u0443\u0442\u0440\u0438 \u0432\u0430\u0448\u0435\u0439 view \u0432\u0441\u0451, \u0447\u0442\u043e \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f, \u0431\u0435\u0437 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0441\u043b\u043e\u0451\u0432, \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u044f\u0442\u044c \u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c CAShapeLayer. \u041d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c override \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 <strong>layerClass<\/strong> \u0443 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0439 view, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044f ShapeLayer.self, \u0438 \u0442\u0430\u043a \u0436\u0435 \u043a\u0430\u043a \u0438 \u0432 \u041f\u0440\u0438\u043c\u0435\u0440\u0435 1 \u0437\u0430\u0434\u0430\u0442\u044c \u044d\u0442\u043e\u043c\u0443 \u0441\u043b\u043e\u044e path.<\/p>\n<p>\u0415\u0441\u0442\u044c \u043e\u0434\u0438\u043d \u043d\u044e\u0430\u043d\u0441, \u043d\u0435 \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044b\u0439 \u0440\u0430\u043d\u0435\u0435. \u041f\u0440\u0438 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0438 \u043d\u0435\u043f\u0440\u0435\u0440\u044b\u0432\u043d\u043e\u0433\u043e \u043f\u0443\u0442\u0438 \u043f\u0440\u0438 \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0444\u043e\u0440\u043c\u044b \u043c\u043e\u0436\u043d\u043e \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u043f\u0435\u0440\u0435\u043f\u0440\u044b\u0433\u043d\u0443\u0442\u044c \u0438\u0437 \u043a\u043e\u043d\u0446\u0430 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u043b\u0438\u043d\u0438\u0438 \u0432 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u0434\u0440\u0443\u0433\u043e\u0435 \u043c\u0435\u0441\u0442\u043e. \u0422\u0438\u043f\u0438\u0447\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u2013 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u043a\u0443\u0441\u043a\u0430 \u043e\u043a\u0440\u0443\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0438 \u043d\u0435\u043f\u0443\u0441\u0442\u043e\u043c path. \u0412 \u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 CoreGraphics \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0430\u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043e\u0440\u0438\u0441\u0443\u0435\u0442 \u0437\u0430 \u0432\u0430\u0441 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u044e\u0449\u0443\u044e \u043b\u0438\u043d\u0438\u044e, \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u044e\u0449\u0443\u044e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u0442\u043e\u0447\u043a\u0443 \u043f\u0443\u0442\u0438 \u0438 \u043d\u043e\u0432\u0443\u044e \u0442\u043e\u0447\u043a\u0443 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c\u043e\u0439 \u043b\u0438\u043d\u0438\u0438. \u0412 \u0441\u043e\u0432\u043e\u043a\u0443\u043f\u043d\u043e\u0441\u0442\u0438 \u0441 <strong>fillRule <\/strong>\u0443 CAShapeLayer \u044d\u0442\u0438\u043c \u043c\u043e\u0436\u043d\u043e \u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0430 \u0442\u0440\u0435\u0442\u044c\u0435\u0439 \u0441\u043f\u0440\u0430\u0432\u0430 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0435 (\u043a\u0430\u0440\u0442\u0430 \u0442\u0440\u0435\u0444) \u044d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u0435: \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0434\u0443\u043c\u0430\u0442\u044c \u043e \u0442\u043e\u043c, \u0432 \u043a\u0430\u043a\u0438\u0445 \u0438\u043c\u0435\u043d\u043d\u043e \u043c\u0435\u0441\u0442\u0430\u0445 \u043f\u0435\u0440\u0435\u0441\u0435\u043a\u0430\u044e\u0442\u0441\u044f \u043e\u043a\u0440\u0443\u0436\u043d\u043e\u0441\u0442\u0438. <\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u0438\u043a\u0438<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"swift\">import UIKit  final class SpadeCardView: UIView {      var selfLayer: CAShapeLayer { layer as! CAShapeLayer }   private let inset: CGFloat = 20      \/\/ MARK: Override      static override var layerClass: AnyClass {<\/code><\/pre>\n<\/div>\n<\/details>\n<p><\/br><\/p>\n<p><\/br><\/br><\/a><\/br><\/br><\/p>\n<p><\/br><\/br><\/br><\/p>\n<p><\/br><\/br><\/br><\/br><\/br><\/p>\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-320391","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/320391","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=320391"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/320391\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=320391"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=320391"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=320391"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}