Domanda

I'm new to iOS, I want to divide the UIView frame in to N equals size UIView frame based on the center point of the UIView.

For Example i done for the circle: http://s14.postimg.org/6w4xfa80h/i_OS_Simulator_Screen_shot_Mar_31_2014_7_03_03_P.png

Same way i have to do. but the shape of the view corner is not the arc, it should be same as view rectangle frame.

How can i achieve.

È stato utile?

Soluzione

If I understand correctly, what you're trying to do is creating views that look like the following:

8-way split

Note that the areas are not rectangular, so they cannot be view frames. They are shapes that can be created via CGPath functions. An easy way to create those lines is with CGPathAddLineToPoint. Always add a line that starts at the center of the view and goes down far the y coordinate. All you have to do is change the CGAffineTransform *m parameter by calling repeatedly CGAffineTransformRotate with an angle = 2*pi/n where n is the number of equal parts.

Assuming you have a CGAffineTransform t and the aforementioned angle, you'd loop n times:

CGPathRef path = CGPathCreateMutable(); CGPathAddLineToPoint(path, CGAffineTransformRotate(t,angle), view.frame.center.x, view.frame.center.y + view.frame.size.y); // Now do something with that line....

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top