Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/108.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UIImageView,带有两个用于边框的Calayer_Ios_Objective C_Ios6_Calayer_Caanimation - Fatal编程技术网

Ios UIImageView,带有两个用于边框的Calayer

Ios UIImageView,带有两个用于边框的Calayer,ios,objective-c,ios6,calayer,caanimation,Ios,Objective C,Ios6,Calayer,Caanimation,我有一个UIImageView,我正试图使用CALayer 我的边界实际上由两个边界组成…内边界将是5像素宽的白色,外边界将是1像素宽的浅灰色 我可以通过以下方式轻松完成第一部分: myImageView.layer.borderColor = [UIColor whiteColor].CGColor; myImageView.layer.borderColorWidth = 5.0f; 但是我正在努力为它添加一个额外的1px灰色边框。你可以制作一个“背景视图”作为你的myImageView的

我有一个UIImageView,我正试图使用
CALayer

我的边界实际上由两个边界组成…内边界将是5像素宽的白色,外边界将是1像素宽的浅灰色

我可以通过以下方式轻松完成第一部分:

myImageView.layer.borderColor = [UIColor whiteColor].CGColor;
myImageView.layer.borderColorWidth = 5.0f;
但是我正在努力为它添加一个额外的1px灰色边框。

你可以制作一个“背景视图”作为你的
myImageView的超级视图。
背景视图比你的
myImageView
大1px“背景视图”的背景颜色是浅灰色。然后将您的
myImageView
添加为子视图

您可以创建一个“背景视图”作为您的
myImageView的超级视图
该“背景视图”比您的
myImageView
大1倍“背景视图”的背景色为浅灰色。然后将您的
myImageView
添加为子视图

randomView.layer.borderColor=[[UIColor COLOR WITHRED:0.8f绿色:0.8f蓝色:0.8f alpha:1.0f]CGColor]; randomView.layer.borderWidth=1.0f

试试这个

randomView.layer.borderColor=[[UIColor COLOR WITHRED:0.8f绿色:0.8f蓝色:0.8f alpha:1.0f]CGColor];
randomView.layer.borderWidth=1.0f

可能您可以将此imageView作为子视图添加到另一个较大的视图,然后为新视图添加图层边框。可能您可以将此imageView作为子视图添加到另一个较大的视图,然后为新视图添加图层边框。此解决方案在大多数情况下都有效。不过,让我的案例有点不同的是,我将imageview缩小到图像大小,以便图像周围的边界保持一致。这种解决方案在大多数情况下都有效。不过,让我的案例有点不同的是,我将imageview缩小到图像大小,以便图像周围的边界保持一致。