简单一段代码实现控件按自己想要弧度加载

#define Heig [UIScreen mainScreen].bounds.size.height
#define kTurntableNum 10
#define DEGREES_TO_RADIANS(d) (d * M_PI / 180)

CGFloat angle = DEGREES_TO_RADIANS((180.0/kTurntableNum));
//    currentTag = 0;
for (int i = 0; i < kTurntableNum; i++)
{
UIButton *button1 = [UIButton buttonWithType:UIButtonTypeCustom];
button1.tag = i;
//55,55
[button1 setFrame:CGRectMake(13.5/667.0*Heig,64+(66+235- 27.5)/667.0*Heig ,56/667.0*Heig, 56/667.0*Heig)];
//        position.x = frame.origin.x + 0.5 * bounds.size.width;
//        position.y = frame.origin.y + 0.5 * bounds.size.height;
button1.layer.anchorPoint = CGPointMake(0.5,4.7);//(0.5,1.0)
button1.layer.transform= CATransform3DMakeRotation(angle * i *1.113,0.0, 0.0, 1.0);
[button1 setTitle:@(i).stringValue forState:UIControlStateNormal];
button1.backgroundColor = [UIColor yellowColor];
button1.layer.masksToBounds = YES;
button1.layer.cornerRadius = 28/667.0*Heig;
[button1 addTarget:self action:@selector(buttonDown:)  forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button1];
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容