Pracuję na wykresie kołowym i muszę dodać mały widok na końcu zaznaczonego koła (nie cienia), aby wskazać wartość docelową. Czy mogę znaleźć okrąg (podświetlenie) super widok x, y pozycje oparte na punkcie końcowym obrysu?Jak uzyskać pozycję podglądu w CAShapeLayer?
UIView->Circle
(przy użyciu CAShapeLayer
i UIBezierPath
). Muszę uzyskać pozycję UIView
na podstawie wartości obrysu kończącej się Circle
.
Proszę odnieść ten link (podobnie jak 23% z linią przerywaną) http://support.softwarefx.com/media/74456678-5a6a-e211-84a5-0019b9e6b500/large
Z góry dzięki! Need to find green end circle position
Aktualizacja: Próbowałem alexburtnik kod faktycznie pracuję na wykresie zegara w Objective C, ale to nie jest problem. Próbowałem jak wspomniałem alexburtnik, uważam, że doskonale działa na wykresie zegara. Musimy wprowadzić pewne zmiany w kodzie, aby działały również w kierunku zgodnym z ruchem wskazówek zegara, proszę podać rozwiązanie, jeśli wiesz.
CGFloat radiusCircle = (self.frame.size.height * 0.5) - ([_lineWidth floatValue]/2.0f);
-(void)addTargetViewWithOptions:(CGFloat)progress andRadius:(CGFloat)radius{
CGFloat x = radius * (1 + (cos(M_PI * (2 * progress + 0.5))));
CGFloat y = radius * (1 - (sin(M_PI * (2 * progress + 0.5))));
UIView *targetView = [[UIView alloc]initWithFrame:CGRectMake(x, y, 40, 30)];
targetView.backgroundColor = [UIColor greenColor];
[self addSubview:targetView];}
i starałem jak esthepiking wspomniano, tutaj I dodaje kod i zrzut ekranu
-(void)addTargetView{
CGFloat endAngle = -90.01f;
radiusCircle = (self.frame.size.height * 0.5) - ([_lineWidth floatValue]/2.0f);
endAngleCircle = DEGREES_TO_RADIANS(endAngle);//-1.570971
// Size for the text
CGFloat width = 75;
CGFloat height = 30;
// Calculate the location of the end of the stroke
// Cos calculates the x position of the point (in unit coordinates)
// Sin calculates the y position of the point (in unit coordinates)
// Then scale this to be on the range [0, 1] to match the view
CGFloat endX = (cos(endAngleCircle)/2 + 0.5);
CGFloat endY = (sin(endAngleCircle)/2 + 0.5);
// Scale the coordinates to match the diameter of the circle
endX *= radiusCircle * 2;
endY *= radiusCircle * 2;
// Translate the coordinates based on the location of the frame
endX -= self.frame.origin.x;
endY -= self.frame.origin.y;
// Vertically align the label
endY += height;
// Setup the label
UIView *targetView = [[UIView alloc]initWithFrame:CGRectMake(endX, endY, width, height)];
targetView.backgroundColor = [UIColor redColor];
[self addSubview:targetView];}
convertPoint: toView: powinno załatwić sprawę – Alex