在Interface Builder中设置蒙版角 [英] Setting masked corners in Interface Builder
问题描述
[.layerMaxXMinYCorner, .layerMinXMinYCorner]
是什么类型的值?是否可以在Interface Builder中的View上设置此参数?我知道如何在身份检查器中设置layer.borderWidth
,layer.borderUIColor
和layer.cornerRadius
,但是我无法弄清楚用于遮罩角的正确类型和值.
What type of value is [.layerMaxXMinYCorner, .layerMinXMinYCorner]
? Is it possible to set this parameter on a View in Interface Builder? I know how to set layer.borderWidth
, layer.borderUIColor
and layer.cornerRadius
in the Identity Inspector, but I can't figure out the right Type and Value to use for masked corners.
谢谢!
杰克
更新:以下是每个组合的整数值(按四舍五入的方式):
Update: here are the integer values for each combination (in terms of which are rounded):
- 0:没有圆角
- 1:左上方
- 2:右上方
- 3 :左上方&右(两个顶角)
- 4:左下方
- 5:顶部&左下角(两个角)
- 6 :右上角&左下方
- 7 :左上方&右,左下(除右下外的所有角落)
- 8:右下角
- 9 :左上方,右下方
- 10:顶部&右下角(两个角)
- 11::两个右上角,右下角(左下角以外的所有角)
- 12 :左下角&右(两个底角)
- 13 :左下角&右,左上(除右上外的所有角落)
- 14 :左下角&右上,右上(除左上角外的所有角落)
- 15 :所有角都是圆角的
- 0: no rounded corners
- 1: top left
- 2: top right
- 3: top left & right (both top corners)
- 4: bottom left
- 5: top & bottom left (both left corners)
- 6: top right & bottom left
- 7: top left & right, bottom left (all corners except bottom right)
- 8: bottom right
- 9: top left, bottom right
- 10: top & bottom right (both right corners)
- 11: both top corners, bottom right (all corners except bottom left)
- 12: bottom left & right (both bottom corners)
- 13: bottom left & right, top left (all corners except top right)
- 14: bottom left & right, top right (all corners except top left)
- 15: all corners rounded
- 左上角位于1、3、5、7、9、11、13、15
- 右上角是2-3、6-7、10-11、14-15
- 左下角是4-7、12-15
-
右下角是8-15
- Top left is in 1, 3, 5, 7, 9, 11, 13, 15
- Top right is in 2-3, 6-7, 10-11, 14-15
- Bottom left is in 4-7, 12-15
Bottom right is in 8-15
两个上角位于3、7、11、15
Both top corners are in 3, 7, 11, 15
推荐答案
maskedCorners
是CACornerMask,它是一个OptionSet或位掩码.原始值是一个整数:在代码中,您可以尝试打印someView.layer.maskedCorners.rawValue
的值,或通过someView.layer.maskedCorners.setValue(3, forKey: "maskedCorners")
进行设置.
maskedCorners
is a CACornerMask, which is an OptionSet, or bit mask. The raw value is an integer: in code, you can try printing the value of someView.layer.maskedCorners.rawValue
, or setting it via someView.layer.maskedCorners.setValue(3, forKey: "maskedCorners")
.
因此,您应该能够在Interface Builder中将layer.maskedCorners
的值设置为整数3(或任何您需要的值),我不明白为什么这样做不安全.如果您忘记了,那么找出整数值实际映射到哪些角点将是一件很痛苦的事情.
So you should be able to set the value of layer.maskedCorners
to the integer 3 (or whatever you need) in Interface Builder, and I don't see why it would be unsafe to do this. Though it will be a pain to figure out what set of corners that integer value actually maps to if you forget.
这篇关于在Interface Builder中设置蒙版角的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!