在UIView上设置多个边框 [英] Setting multiple borders on UIView
本文介绍了在UIView上设置多个边框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
由于我找不到任何问题/答案,我想这是不可能的。
As I cannot find any questions/answers for this, I imagine it is not possible.
无论如何在的UIView
。
我目前正在设置标准边框<。c $ c> .layer.borderWidth 和 layer.borderColor
。我想知道我是否可以为视图添加多笔画/边框效果。
I am currently setting a standard border with .layer.borderWidth
and layer.borderColor
. I am wondering if I can add a multiple strokes/borders effect to the view.
我需要一个白色的4.0f边框,然后另一个颜色的另一个1.0f。
I need a border of 4.0f in white then another 1.0f in another color.
推荐答案
我能想到的三个解决方案:
Three solutions I can think of:
- 在另一个中嵌套一个UIView,为每个定义一个边框;
- 自己在
中绘制边框 - (void)drawRect
; - 使用
UIImageView
带有可调整大小;作为背景的边框的可伸缩图像(性能最佳解决方案)。
- nest a UIView in another one, define one border for each;
- draw the border yourself in
-(void)drawRect
; - use an
UIImageView
with a resizable; stretchable image of your borders as background (the best solution performance-wise).
这篇关于在UIView上设置多个边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文