{"id":284952,"date":"2017-04-13T18:02:30","date_gmt":"2017-04-13T14:02:30","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=284952"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=284952","title":{"rendered":"\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u043e\u0433\u043e UI-\u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0434\u043b\u044f \u0432\u044b\u0431\u043e\u0440\u0430 \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u0427\u0430\u0441\u0442\u044c 2"},"content":{"rendered":"<p>\u0412 <a href=\"https:\/\/habrahabr.ru\/company\/e-Legion\/blog\/326324\/\">\u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438<\/a> \u0441\u0442\u0430\u0442\u044c\u0438 \u044f \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0432\u043e\u0441\u0441\u043e\u0437\u0434\u0430\u043b \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0446\u0438\u0444\u0435\u0440\u0431\u043b\u0430\u0442\u0430. \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043f\u043e\u0434\u043e\u0448\u043b\u0438 \u043a \u0441\u0430\u043c\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u043c\u0443 \u0438 \u0441\u043b\u043e\u0436\u043d\u043e\u043c\u0443 \u044d\u0442\u0430\u043f\u0443 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0430.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h4><b>\u0412\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u0446\u0438\u0444\u0435\u0440\u0431\u043b\u0430\u0442\u0430<\/b><\/h4>\n<p>  \u0417\u0434\u0435\u0441\u044c \u044f \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0443 \u0432\u0440\u0430\u0449\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u043f\u043e \u0441\u043e\u0432\u0435\u0442\u0443 \u0438\u0437 \u0434\u043e\u043a\u043b\u0430\u0434\u0430, \u043e\u0437\u0432\u0443\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u043d\u0430 <a href=\"https:\/\/mbltdev.ru\/ru\">MBLTdev<\/a>.<\/p>\n<p>  \u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u043d\u043e\u0439 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0435\u0439 \u0443 \u043d\u0430\u0441 \u0441\u043b\u0443\u0436\u0438\u0442 <code>contentOffset<\/code> \u0443 <code>scrollView<\/code>. \u041d\u0430 \u044d\u0442\u043e\u0439 \u043e\u0441\u043d\u043e\u0432\u0435 \u043c\u044b \u0441\u0447\u0438\u0442\u0430\u0435\u043c \u0443\u0433\u043e\u043b \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u0430.<\/p>\n<p>  \u0412\u0432\u0435\u0434\u0435\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0442\u0435\u043a\u0443\u0449\u0435\u043c \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u043a\u0440\u0443\u0442\u0438\u043b\u043a\u0438.<\/p>\n<pre><code class=\"objectivec\">@property (assign, nonatomic) CGFloat currentAngle; @property (assign, nonatomic) CGPoint startPoint; @property (assign, nonatomic) CGFloat previousAngle;<\/code><\/pre>\n<p>  \u041d\u0430\u043c \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043b\u0438\u043d\u044b \u043e\u043a\u0440\u0443\u0436\u043d\u043e\u0441\u0442\u0438.<\/p>\n<pre><code class=\"objectivec\">@property (assign, nonatomic, readonly) CGFloat circleLength; <\/code><\/pre>\n<p>  \u0414\u0435\u043b\u0430\u0435\u043c \u0435\u0433\u043e, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0440\u0430\u0434\u0438\u0443\u0441 \u043e\u043a\u0440\u0443\u0436\u043d\u043e\u0441\u0442\u0438. \u041f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c <code>setter<\/code>.<\/p>\n<pre><code class=\"objectivec\">- (void)setCircleRadius:(CGFloat)circleRadius {     _circleRadius = circleRadius;          _circleLength = 2 * M_PI * circleRadius; }<\/code><\/pre>\n<p>  \u041f\u0440\u043e\u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c <code>startPoint<\/code> \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 <code>- (void)commonInit<\/code> \u043a\u0430\u043a \u0441\u0435\u0440\u0435\u0434\u0438\u043d\u0443 <code>contentOffset<\/code>, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0432 \u043e\u0431\u0435 \u0441\u0442\u043e\u0440\u043e\u043d\u044b.<\/p>\n<pre><code class=\"objectivec\">    self.startPoint = self.scrollView.contentOffset; <\/code><\/pre>\n<p>  \u041f\u0440\u0438\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u0434\u0435\u043b\u0430\u043d\u044b. \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0440\u0430 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043a \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0435. \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0435 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u0442\u043e\u0447\u043a\u0430\u043c\u0438. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0444\u043e\u0440\u043c\u0443\u043b\u0443 \u2014 \u043a\u043e\u0440\u0435\u043d\u044c \u0438\u0437 \u0441\u0443\u043c\u043c\u044b \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043e\u0432 \u0440\u0430\u0437\u043d\u043e\u0441\u0442\u0435\u0439 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442.<\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/4fb\/0d4\/8dc\/4fb0d48dc8edaff7119a8e11f20b35be.svg\" alt=\"$d = \\sqrt {{{({x_2} - {x_1})}^2} + {{({y_2} - {y_1})}^2}}$\" data-tex=\"display\"\/><\/math><\/p>\n<p>  \u0412 \u043a\u043e\u0434\u0435 \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"objectivec\">- (CGFloat)deltaWithOffset:(CGPoint)offset {     return sqrt(pow(self.startPoint.x - offset.x, 2) + pow(self.startPoint.y - offset.y, 2)); }<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f, \u0442\u043e \u0435\u0441\u0442\u044c \u0437\u043d\u0430\u043a \u0443 \u0434\u043b\u0438\u043d\u044b. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c, \u0432 \u043a\u0430\u043a\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0446\u0435\u043d\u0442\u0440\u0430 \u043a\u0440\u0443\u0433\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0442\u043e\u0447\u043a\u0430 \u043a\u0430\u0441\u0430\u043d\u0438\u044f. \u041f\u043e\u0447\u0435\u043c\u0443 \u044d\u0442\u043e \u0432\u0430\u0436\u043d\u043e? \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u043a\u0430\u043a \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0439 \u0436\u0435\u0441\u0442 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0440\u0430\u0437\u043d\u043e\u043c\u0443 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044e \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f. \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u0447\u0435\u0441\u0442\u044c \u044d\u0442\u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/63c\/fc9\/4df\/63cfc94dfc20474c9e3664fd44db9c8b.png\"\/><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/11f\/32a\/df5\/11f32adf589c434baa144d42d6fc36e6.png\"\/><\/p>\n<p>  \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u0442\u0438\u043f, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0442\u043e\u0447\u043a\u0438 \u0441\u043b\u0435\u0432\u0430 \u0438 \u0441\u043f\u0440\u0430\u0432\u0430 \u043e\u0442 \u0446\u0435\u043d\u0442\u0440\u0430 \u043a\u0440\u0443\u0433\u0430,<\/p>\n<pre><code class=\"objectivec\">typedef NS_ENUM(NSUInteger, AYNCircleViewHalf) {     AYNCircleViewHalfLeft,     AYNCircleViewHalfRight, };<\/code><\/pre>\n<p>  \u0438 \u043c\u0435\u0442\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e \u0442\u043e\u0447\u043a\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435:<\/p>\n<pre><code class=\"objectivec\">- (AYNCircleViewHalf)halfWithPoint:(CGPoint)point {     return point.x &gt; self.contentView.center.x ? AYNCircleViewHalfRight : AYNCircleViewHalfLeft; }<\/code><\/pre>\n<p>  \u0413\u043e\u0442\u043e\u0432\u043e. \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0437\u043d\u0430\u0435\u043c \u0432 \u043a\u0430\u043a\u043e\u0439 \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0435 \u043a\u0440\u0443\u0433\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0442\u043e\u0447\u043a\u0430.<\/p>\n<p>  \u041d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u044d\u0442\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c \u00ab\u0437\u043d\u0430\u043a\u00bb \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u0430.<\/p>\n<pre><code class=\"objectivec\">- (CGFloat)signWithOffset:(CGPoint)offset half:(AYNCircleViewHalf)half {     CGFloat sign = offset.x &gt; self.startPoint.x ? -1 : 1;          BOOL isYDominant = fabs(offset.y - self.startPoint.y) &gt; fabs(offset.x - self.startPoint.x);     if (isYDominant) {         sign = offset.y &gt; self.startPoint.y ? -1 : 1;         sign *= half == AYNCircleViewHalfLeft ? -1 : 1;     }          return sign; }<\/code><\/pre>\n<p>  \u041d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0437\u043d\u0430\u043a\u0430 \u0438 \u0434\u043b\u0438\u043d\u044b \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c \u0443\u0433\u043e\u043b \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u0430. \u041f\u0443\u0441\u0442\u044c delta \u2014 \u044d\u0442\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u043b\u0438\u043d \u043e\u043a\u0440\u0443\u0436\u043d\u043e\u0441\u0442\u0438 \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0438. \u0422\u043e\u0433\u0434\u0430 \u0443\u0433\u043e\u043b \u2014 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 2<math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/5b0\/d3c\/e30\/5b0d3ce300101c511c94801c53b6b428.svg\" alt=\"$\\pi$\" data-tex=\"inline\"\/><\/math> \u0440\u0430\u0434\u0438\u0430\u043d \u043d\u0430 <code>delta<\/code>.<\/p>\n<pre><code class=\"objectivec\">- (CGFloat)angleWithOffset:(CGPoint)offset half:(AYNCircleViewHalf)half {     CGFloat delta = [self deltaWithOffset:offset] \/ self.circleLength;          CGFloat sign = [self signWithOffset:offset half:half];          return sign * delta * 2 * M_PI; }<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043c\u0435\u0442\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043d\u0438\u043c\u0430\u0442\u044c \u043b\u0438\u0448\u043d\u0438\u0435 \u043f\u0435\u0440\u0438\u043e\u0434\u044b \u0443 \u0443\u0433\u043b\u043e\u0432. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0443\u0433\u043e\u043b \u0432 3<math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/5b0\/d3c\/e30\/5b0d3ce300101c511c94801c53b6b428.svg\" alt=\"$\\pi$\" data-tex=\"inline\"\/><\/math> \u0434\u043e <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/5b0\/d3c\/e30\/5b0d3ce300101c511c94801c53b6b428.svg\" alt=\"$\\pi$\" data-tex=\"inline\"\/><\/math>. \u041d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0438 \u0441 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u0443\u0433\u043b\u0430\u043c\u0438.<\/p>\n<pre><code class=\"objectivec\">- (CGFloat)floorAngle:(CGFloat)angle {     NSInteger times = floorf(fabs(angle) \/ (2 * M_PI));          NSInteger sign = angle &gt; 0 ? -1 : 1;          return angle + sign * times * 2 * M_PI; }<\/code><\/pre>\n<p>  \u0413\u043e\u0442\u043e\u0432\u043e, \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0431\u0430\u0437\u0430 \u0434\u043b\u044f \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u0430 \u043d\u0430\u0448\u0435\u0433\u043e \u043a\u0440\u0443\u0433\u0430.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043f\u043e\u0432\u043e\u0440\u043e\u0442 \u0432\u0441\u0435\u0439 \u043d\u0430\u0448\u0435\u0439 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0438. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043c\u0435\u0442\u043e\u0434 \u043d\u0430\u0434 <code>UIView +<\/code> <code>- (void)animateWithDuration:animations:<\/code>.<\/p>\n<pre><code class=\"objectivec\">- (void)rotateWithAngle:(CGFloat)angle {     [UIView animateWithDuration:0.1 animations:^{         self.contentView.transform = CGAffineTransformMakeRotation(angle);     }]; }<\/code><\/pre>\n<p>  \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u043d\u0435 \u043e\u0441\u043b\u0430\u0431\u043b\u044f\u0435\u043c \u0441\u0441\u044b\u043b\u043a\u0443, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043a\u043e\u0433\u0434\u0430 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044f \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u0442\u0441\u044f, \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 <code>self<\/code> \u043f\u0440\u043e\u043f\u0430\u0434\u0435\u0442.<\/p>\n<p>  \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u043c\u0435\u0442\u043e\u0434 \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0430 <code>- (void)scrollViewDidScroll:<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c \u0432\u0441\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f:<\/p>\n<pre><code class=\"objectivec\">- (void)scrollViewDidScroll:(UIScrollView *)scrollView {     CGPoint point = [scrollView.panGestureRecognizer locationInView:self];          CGFloat tickOffset = [self angleWithOffset:scrollView.contentOffset half:[self halfWithPoint:point]];     self.currentAngle = [self floorAngle:(self.previousAngle + tickOffset)];          [self rotateWithAngle:self.currentAngle];          self.previousAngle = self.currentAngle;     self.startPoint = scrollView.contentOffset; }<\/code><\/pre>\n<p>  \u0413\u043e\u0442\u043e\u0432\u043e. \u0421\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442. <\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/ad8\/8ba\/8c5\/ad88ba8c5b744b30a415dae1582918b4.gif\"\/><\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0442\u0430\u043a\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0430, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0441\u043b\u0435 \u0441\u0438\u043b\u044c\u043d\u043e\u0439 \u043f\u0440\u043e\u043a\u0440\u0443\u0442\u043a\u0438 \u043e\u043d \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u043b\u0441\u044f \u0440\u043e\u0432\u043d\u043e \u043d\u0430 \u043a\u0430\u043a\u043e\u043c-\u043b\u0438\u0431\u043e \u0447\u0438\u0441\u043b\u0435. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u0438 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c <code>targetContentOffset<\/code> \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0430 <code>- (void)scrollViewWillEndDragging:withVelocity:targetContentOffset:<\/code>. \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u043c \u043d\u0430\u0448 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043f\u043f\u0430\u0440\u0430\u0442.<\/p>\n<p>  \u041f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c, \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0443\u0433\u043e\u043b \u0434\u043e \u043a\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u043a <code>angleStep<\/code>. \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434. <\/p>\n<pre><code class=\"objectivec\">- (CGFloat)normalizeAngle:(CGFloat)angle {     return lroundf(angle \/ self.angleStep) * self.angleStep; }<\/code><\/pre>\n<p>  \u041e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c\u0441\u044f \u043d\u0430 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u00ab\u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u0439\u00bb \u0442\u043e\u0447\u043a\u0438 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 <code>scrollView<\/code>. \u041c\u0435\u0442\u043e\u0434 <code>- (void)scrollViewWillEndDragging:withVelocity:targetContentOffset:<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <code>contentOffset<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 <code>scrollView<\/code>. \u041d\u0430\u0448\u0430 \u0446\u0435\u043b\u044c \u2014 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u044d\u0442\u043e\u0442 <code>CGPoint<\/code>. \u041e\u0442\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u0435\u043c\u0441\u044f \u043e\u0442 \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u0438\u043d\u044b \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/0f7\/f7e\/ed7\/0f7f7eed71a24112a4b4726026cc455c.png\"\/><\/p>\n<p>  \u041f\u0443\u0441\u0442\u044c <code>target<\/code> \u2014 \u044d\u0442\u043e <code>targetContentOffset<\/code>. \u0420\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c \u0442\u0430\u043a\u0443\u044e \u0442\u043e\u0447\u043a\u0443 <code>normalizedContentOffset<\/code>, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u0430\u044f \u0434\u043b\u0438\u043d\u0430 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u043b\u0430\u0441\u044c \u0432 \u0443\u0433\u043e\u043b \u043a\u0440\u0430\u0442\u043d\u044b\u0439 <code>angleStep<\/code>. \u0422\u043e\u0433\u0434\u0430 \u043a\u043e\u043d\u0442\u0440\u043e\u043b \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442 \u0432\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u0442\u043e\u0447\u043d\u043e \u043d\u0430 \u0447\u0438\u0441\u043b\u0435.<\/p>\n<p>  \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u0435\u043c \u00ab\u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u0443\u044e\u00bb \u0434\u043b\u0438\u043d\u0443 \u0438, \u0437\u043d\u0430\u044f \u0443\u0433\u043e\u043b \u043d\u0430\u043a\u043b\u043e\u043d\u0430 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f, \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043a\u043e\u043d\u0446\u0430 \u044d\u0442\u043e\u0433\u043e \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f. \u0418\u0437\u043c\u0435\u043d\u0438\u0432 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b, \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u0438 \u0442\u043e\u0447\u043a\u0443 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438.<\/p>\n<p>  \u0418\u0442\u0430\u043a, \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f:<\/p>\n<p>  \u2014 \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u0434\u043b\u0438\u043d\u0443 \u043f\u043e \u0442\u0435\u043a\u0443\u0449\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c <code>startPoint<\/code>, <code>targetPoint<\/code>,<br \/>  \u2014 \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u0443\u0433\u043e\u043b \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u0430 \u043f\u043e \u0434\u043b\u0438\u043d\u0435,<br \/>  \u2014 \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0443\u0433\u043e\u043b,<br \/>  \u2014 \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u0434\u043b\u0438\u043d\u0443,<br \/>  \u2014 \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u043a\u043e\u043d\u0435\u0447\u043d\u0443\u044e \u0442\u043e\u0447\u043a\u0443 \u043d\u0430 \u043d\u043e\u0432\u043e\u0439 \u0434\u043b\u0438\u043d\u0435.<\/p>\n<p>  \u041d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u043c \u043f\u0443\u043d\u043a\u0442\u0435 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c\u0441\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e. \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043d\u0430\u0439\u0442\u0438 \u043f\u0440\u043e\u0435\u043a\u0446\u0438\u0438 \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u043d\u0430 \u043e\u0441\u0438 \u041e\u0445 \u0438 \u041e\u0443. \u042d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u0437\u043d\u0430\u044f \u0443\u0433\u043e\u043b \u043d\u0430\u043a\u043b\u043e\u043d\u0430 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f. \u0412\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c \u0442\u0430\u043d\u0433\u0435\u043d\u0441 \u0443\u0433\u043b\u0430 \u043d\u0430\u043a\u043b\u043e\u043d\u0430 \u043a\u0430\u043a \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/631\/d48\/60a\/631d4860acb47a386f75a46f77e41af0.svg\" alt=\"$tg\\alpha = \\frac{y}{x}$\" data-tex=\"display\"\/><\/math><\/p>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u044d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435, \u0441 \u043b\u0435\u0433\u043a\u043e\u0441\u0442\u044c\u044e \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043a\u043e\u043d\u0446\u0430 \u201c\u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e\u201d \u043e\u0442\u0440\u0435\u0437\u043a\u0430.<\/p>\n<pre><code class=\"objectivec\">- (CGPoint)endPointWithTargetPoint:(CGPoint)targetPoint scrollView:(UIScrollView *)scrollView {     CGPoint point = [scrollView.panGestureRecognizer locationInView:self];          CGFloat tickOffset = [self angleWithOffset:targetPoint half:[self halfWithPoint:point]];      CGFloat rotationAngle = self.previousAngle + tickOffset;     CGFloat delta = [self deltaWithAngle:rotationAngle];     CGFloat normalizedRotationAngle = [self normalizeAngle:rotationAngle];     CGFloat normalizedDelta = [self deltaWithAngle:normalizedRotationAngle];      CGFloat inclination = [self inclinationWithOffset:targetPoint startPoint:self.startPoint];          CGFloat sign = normalizedRotationAngle &lt;= 0 ? -1 : 1;          CGPoint result = CGPointMake(targetPoint.x + sign * (normalizedDelta - delta) * cos(inclination), targetPoint.y + sign * (normalizedDelta - delta) * sin(inclination));      return result; }<\/code><\/pre>\n<p>  \u041c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0443\u0433\u043b\u0430 \u043d\u0430\u043a\u043b\u043e\u043d\u0430 \u043d\u0430\u0448\u0435\u0433\u043e \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"objectivec\">- (CGFloat)inclinationWithOffset:(CGPoint)offset startPoint:(CGPoint)startPoint {     CGFloat y = (offset.y - self.startPoint.y);     CGFloat x = (offset.x - self.startPoint.x);          if (!isnan(x) && x != 0) {         return atan2(y, x);     }          return 0; }<\/code><\/pre>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <a href=\"https:\/\/en.wikipedia.org\/wiki\/Atan2#Definition_and_computation\">atan2<\/a>, \u0442.\u043a. \u043e\u043d\u0430 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u0443\u0433\u043b\u044b \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0447\u0435\u0442\u0432\u0435\u0440\u0442\u0438.<\/p>\n<p>  \u0413\u043e\u0442\u043e\u0432\u043e. \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043c\u0435\u0442\u043e\u0434 \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043c \u0440\u0430\u0441\u0447\u0435\u0442\u044b:<\/p>\n<pre><code class=\"objectivec\">- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset {      *targetContentOffset = [self endPointWithTargetPoint:*targetContentOffset scrollView:scrollView]; }<\/code><\/pre>\n<p>  \u0411\u044b\u0432\u0430\u044e\u0442 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438, \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u0440\u043e\u043a\u0440\u0443\u0442\u0438\u043b \u0442\u0430\u043a \u043c\u0430\u043b\u043e, \u0447\u0442\u043e \u043d\u0435 \u0434\u043e\u0441\u0442\u0438\u0433 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0438\u043b\u0438 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u0447\u0438\u0441\u043b\u0430. \u0422\u043e\u0433\u0434\u0430 \u043a\u043e\u043d\u0442\u0440\u043e\u043b \u0434\u043e\u043b\u0436\u0435\u043d \u043e\u0442\u043f\u0440\u044b\u0433\u043d\u0443\u0442\u044c \u043d\u0430 \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0438\u0439. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043c\u0435\u0442\u043e\u0434 \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0430: <\/p>\n<pre><code class=\"objectivec\">- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {     if (!decelerate) {         self.currentAngle = [self normalizeAngle:self.previousAngle];                  [self rotateWithAngle:self.currentAngle];     } }<\/code><\/pre>\n<p>  \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/afe\/e83\/9a0\/afee839a03164dd3811a948bc399fb58.gif\"\/><\/p>\n<h4><b>\u041c\u0435\u0442\u043e\u0434\u044b \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0430<\/b><\/h4>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0430 \u043d\u0430\u0448\u0435\u0439 \u043a\u0440\u0443\u0442\u0438\u043b\u043a\u0438, \u0447\u0442\u043e\u0431 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 \u043c\u043e\u0433\u043b\u0438 \u043d\u0430\u0437\u043d\u0430\u0447\u0430\u0442\u044c \u043a\u0430\u043a\u043e\u0439-\u043b\u0438\u0431\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u0435\u0433\u043e \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u043e\u043c \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u043b\u0438 \u043e\u0442 \u043d\u0435\u0433\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e. \u041d\u043e \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 \u0446\u0438\u0444\u0435\u0440\u0431\u043b\u0430\u0442\u0435:<\/p>\n<pre><code class=\"objectivec\">@property (nonatomic, readonly) NSInteger value; <\/code><\/pre>\n<p>  \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0433\u0435\u0442\u0442\u0435\u0440 \u0434\u043b\u044f \u043d\u0435\u0433\u043e:<\/p>\n<pre><code class=\"objectivec\">- (NSInteger)value {     NSInteger value = self.currentAngle &gt; 0 ? floorf(self.currentAngle \/ self.angleStep) - self.numberOfLabels : floorf(self.currentAngle \/ self.angleStep);          return labs(value) % self.numberOfLabels; }<\/code><\/pre>\n<p>  \u0413\u043e\u0442\u043e\u0432\u043e. \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0443\u0437\u043d\u0430\u0442\u044c \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 \u0446\u0438\u0444\u0435\u0440\u0431\u043b\u0430\u0442\u0435.<\/p>\n<p>  \u0417\u0430\u0439\u043c\u0435\u043c\u0441\u044f \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u043e\u043c.<\/p>\n<pre><code class=\"objectivec\">@protocol AYNCircleViewDelegate &lt;NSObject&gt;  @optional  - (void)circleViewWillRotate:(AYNCircleView *)circleView; - (void)circleView:(AYNCircleView *)circleView didRotateWithValue:(NSUInteger)value;  @end<\/code><\/pre>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u044d\u0442\u0438\u0445 \u0434\u0432\u0443\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0445\u0432\u0430\u0442\u0438\u0442. \u041d\u0430\u0441 \u0431\u043e\u043b\u044c\u0448\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 \u0432\u0442\u043e\u0440\u043e\u0439 \u043c\u0435\u0442\u043e\u0434, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u0440\u0443\u0442\u0438\u043b\u043a\u0438 \u0432 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u043c\u043e\u043c\u0435\u043d\u0442.<\/p>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0430 \u0443 <code>AYNCircleView<\/code>:<\/p>\n<pre><code class=\"objectivec\">@property (weak, nonatomic) id&lt;AYNCircleViewDelegate&gt; delegate; <\/code><\/pre>\n<p>  \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u043c\u0435\u0441\u0442\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u044d\u0442\u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f.<\/p>\n<p>  \u0422\u0430\u043a \u043a\u0430\u043a \u044d\u0442\u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u0441\u0432\u044f\u0437\u0430\u043d\u044b \u0441 \u0432\u0440\u0430\u0449\u0435\u043d\u0438\u0435\u043c, \u0442\u043e \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 <code>- (void)rotateWithAngle:<\/code>.<\/p>\n<p>  \u041a\u0430\u043a \u043e\u043d \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441 \u0432\u044b\u0437\u043e\u0432\u0430\u043c\u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u0432:<\/p>\n<pre><code class=\"objectivec\">- (void)rotateWithAngle:(CGFloat)angle {     if (self.delegate && [self.delegate respondsToSelector:@selector(circleViewWillRotate:)]) {         [self.delegate circleViewWillRotate:self];     }          [UIView animateWithDuration:0.1 animations:^{         self.contentView.transform = CGAffineTransformMakeRotation(angle);     } completion:^(BOOL finished) {         if (self.delegate && [self.delegate respondsToSelector:@selector(circleView:didRotateWithValue:)]) {             [self.delegate circleView:self didRotateWithValue:self.value];         }     }]; }<\/code><\/pre>\n<p>  \u0413\u043e\u0442\u043e\u0432\u043e. \u0420\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0430 \u0432 \u043d\u0430\u0448\u0435\u043c <code>AYNViewController<\/code>.<\/p>\n<p>  \u041d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u0435\u0431\u044f \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u043e\u043c \u044d\u0442\u043e\u0439 \u043a\u0440\u0443\u0442\u0438\u043b\u043a\u0438:<\/p>\n<pre><code class=\"objectivec\">    self.circleView.delegate = self; <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043e\u0434\u0438\u043d \u0438\u0437 \u043c\u0435\u0442\u043e\u0434\u043e\u0432. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0432 <code>Interface Builder<\/code> \u0432\u044b\u0441\u0442\u0430\u0432\u0438\u043c <code>label<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435.<\/p>\n<pre><code class=\"objectivec\">@property (weak, nonatomic) IBOutlet UILabel *valueLabel; <\/code><\/pre>\n<p>  \u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<pre><code class=\"objectivec\">#pragma mark - Circle View Delegate  - (void)circleView:(AYNCircleView *)circleView didRotateWithValue:(NSUInteger)value {     self.valueLabel.text = [NSString stringWithFormat:@&quot;%ld&quot;, value]; }<\/code><\/pre>\n<p>  \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0433\u043e\u0442\u043e\u0432.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/604\/632\/269\/6046322695ea4077b4d1725eaf2f2e81.gif\"\/><\/p>\n<p>  \u0412\u043e\u0442 \u0442\u0430\u043a\u0438\u043c \u043d\u0435\u0445\u0438\u0442\u0440\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u044f \u0438\u0437\u043e\u0431\u0440\u0435\u043b \u0441\u0432\u043e\u0439 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b. \u0412\u0435\u0441\u044c \u043f\u0440\u043e\u0435\u043a\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u043d\u0430 <a href=\"https:\/\/github.com\/haron1020\/CustomControl\">\u0433\u0438\u0442\u0435<\/a>.<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:\/\/habrahabr.ru\/post\/326388\/\"> https:\/\/habrahabr.ru\/post\/326388\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0412 <a href=\"https:\/\/habrahabr.ru\/company\/e-Legion\/blog\/326324\/\">\u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438<\/a> \u0441\u0442\u0430\u0442\u044c\u0438 \u044f \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0432\u043e\u0441\u0441\u043e\u0437\u0434\u0430\u043b \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0446\u0438\u0444\u0435\u0440\u0431\u043b\u0430\u0442\u0430. \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043f\u043e\u0434\u043e\u0448\u043b\u0438 \u043a \u0441\u0430\u043c\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u043c\u0443 \u0438 \u0441\u043b\u043e\u0436\u043d\u043e\u043c\u0443 \u044d\u0442\u0430\u043f\u0443 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0430.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-284952","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/284952","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=284952"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/284952\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=284952"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=284952"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=284952"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}