我有一个数组中的图像,当我在视图上显示这些图像时,它应该带有边框。如何设置边框颜色?
for(UIImage *img in imagesArray)
{
//for bordercolor
}
答案 0 :(得分:3)
首先在 Build Phases =>中添加项目中的QuartzCore.framework
框架Link Binary with Libraries =>添加按钮(+),然后在类中导入其文件,如下面的...
#import <QuartzCore/QuartzCore.h>
并使用波纹管代码设置颜色..
yourImageView.layer.borderWidth = 2.0;
yourImageView.layer.borderColor= [UIColor redColor].CGColor;
<强>更新强>
-(IBAction)lockword:(id)sender {
for (UIImage *img3 in imagesArray) {
UIImageView *imgview1=[[UIImageView alloc]initWithImage:img3];
imgview1.layer.borderWidth = 2.0;
imgview1.layer.borderColor = [UIColor redColor].CGColor;
[imgview1 release];
// your other code write here
// Add this UIImageView as a subview of your view with its frame...
}
}
答案 1 :(得分:1)
#import <QuartzCore/QuartzCore.h>
[imageView.layer setBorderColor: [[UIColor blackColor] CGColor]];
[imageView.layer setBorderWidth: 2.0];
答案 2 :(得分:0)
要允许编辑imageview的边框颜色属性,您需要添加 Quartzcore框架 添加它:链接二进制文件库选项,然后在您想要更改边框颜色的位置编写以下代码:
[imageview.layer setBorderWidth:2.0]; // set the border width to any value you want so that your bordercolor would appear accordingly
[imageview.layer setBorderColor:[[UIColor blueColor].CGColor]; // set the color to whatever background color you want to set to your image