【发布时间】:2023-03-30 20:34:01
【问题描述】:
我在 ViewController 中实现了 iCarousel 方法,一切正常,但有一件事,我想在轮播视图标签下方添加,对于每个图像,我想更改此标签区域中的文本。这是我用于将每个图像创建为按钮的代码。
提前致谢。
UIImage *buttonImage =[NSArray arrayWithObjects:[UIImage imageNamed:@"Hotels.png"],
[UIImage imageNamed:@"image2.png"],
[UIImage imageNamed:@"image3.png"],
[UIImage imageNamed:@"image4.png"],
[UIImage imageNamed:@"image1.png"],
[UIImage imageNamed:@"FastFood.png"],
[UIImage imageNamed:@"Taxi.png"],nil];
UIButton *button =[UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(0, 0, 200.0f, 200.0f);
[button setImage:[buttonImage objectAtIndex:index]forState:UIControlStateNormal]; [按钮 addTarget:self action:@selector(buttonTapped:) forControlEvents:UIControlEventTouchUpInside]; 返回按钮;
【问题讨论】:
-
请正确格式化代码。 UIImage 对象用 NSArray 初始化。
-
抱歉格式不正确,这是我在这里的第一篇文章。取而代之的是 NSArray,我还能用什么来在 iCarousel 中创建带有图像的按钮?
标签: uibutton uilabel icarousel