iphone – 以编程方式在CircleImage上创建UIButtons

iphone – 以编程方式在CircleImage上创建UIButtons,第1张

概述我需要在圆形图像上创建拱形UIButtons.(O / p需要看起来像同心圆), 目前我正在使用5张图片,但将来我可能会添加更多图像,动态地我需要使用添加的图像来填充圆圈图像. 我有一段代码,O / P是下图 int numberOfSections = 6; CGFloat angleSize = 2*M_PI/numberOfSections; for (int j = 0; j < 我需要在圆形图像上创建拱形UIbuttons.(O / p需要看起来像同心圆),

目前我正在使用5张图片,但将来我可能会添加更多图像,动态地我需要使用添加的图像来填充圆圈图像.

我有一段代码,O / P是下图

int numberOfSections = 6;    CGfloat angleSize = 2*M_PI/numberOfSections; for (int j = 0; j < numberOfSections; ++j) {        UIbutton *sectionLabel = [[UIbutton alloc] initWithFrame:CGRectMake(0.0f,0.0f,150.0f,2.0f)];sectionLabel.backgroundcolor = [UIcolor redcolor]; sectionLabel.layer.anchorPoint = CGPointMake(1.0f,0.5f);        sectionLabel.layer.position = CGPointMake(container.bounds.size.wIDth/2.0,container.bounds.size.height/2.0); // places anchorPoint of each label directly in the center of the circle.        sectionLabel.transform = CGAffinetransformMakeRotation(angleSize*j);        [container addSubvIEw:sectionLabel];    }

我试过这段代码,O / P是下图

int numberOfSections = 5;    CGfloat angleSize = 2*M_PI/numberOfSections;    for (int j = 0; j<numberOfSections; ++j) {        UIImage *imageframe = [imagesArray objectAtIndex:j];OBShapedbutton *button = [[OBShapedbutton alloc] initWithFrame:CGRectMake(0.0f,128.0f)];button.transform = CGAffinetransformMakeRotation(angleSize*j);[container addSubvIEw:button];}

我需要输出如下图所示
 

我怎样才能实现这一目标

在我尝试了Sarah Zuo的代码之后的O / P.

      

相同的宽度和高度按钮
AnyKind of Help更受赞赏

解决方法 我只能回答最后一部分,

如果您能够获取按钮的图像,那么您可以参考this tutorial.这可能对您有所帮助.提供,您的图像形成具有透明背景.

总结

以上是内存溢出为你收集整理的iphone – 以编程方式在CircleImage上创建UIButtons全部内容,希望文章能够帮你解决iphone – 以编程方式在CircleImage上创建UIButtons所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1027643.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-23
下一篇2022-05-23

发表评论

登录后才能评论

评论列表(0条)

    保存