截圖: 如果我使用的代碼,然後收到此消息: ,如:類型的值「的UIView」沒有成員cornerRadius 有什麼不對?昨天我沒有這個問題Xcode中的UIView有一個像邊框顏色沒有成員和等
0
A
回答
0
你需要使用Button的圖層來設置border屬性。 e.g:
button.layer.cornerRadius = button.frame.height/2.0
button.layer.masksToBounds = true
button.layer.borderColor = UIColor.lightGray.cgColor
button.layer.borderWidth = 1.0
OR
添加此擴展獲得故事板這些選項。
extension UIView {
@IBInspectable var cornerRadius: CGFloat {
get {
return layer.cornerRadius
}
set {
layer.cornerRadius = newValue
layer.masksToBounds = newValue > 0
}
}
@IBInspectable var borderWidth: CGFloat {
get {
return layer.borderWidth
}
set {
layer.borderWidth = newValue
}
}
@IBInspectable var borderColor: UIColor? {
get {
let color = UIColor.init(cgColor: layer.borderColor!)
return color
}
set {
layer.borderColor = newValue?.cgColor
}
}
@IBInspectable var shadowRadius: CGFloat {
get {
return layer.shadowRadius
}
set {
layer.shadowColor = UIColor.black.cgColor
layer.shadowOffset = CGSize(width: 0, height: 2)
layer.shadowOpacity = 0.4
layer.shadowRadius = shadowRadius
}
}
}
0
它應該是這樣的
#import <QuartzCore/QuartzCore.h>
[[myButton layer] setBorderWidth:2.0f];
[[myButton layer] setBorderColor:[UIColor greenColor].CGColor];
myButton.layer.cornerRadius = myButton.frame.height/2.0;
對於裁判:
0
不能直接設置的CALayer屬性的UIElement。相反,需要使用.layer屬性。
例子:
button.layer.cornerRadius = button.frame.height/ 2.0
button.layer.maskToBounds = true
相關問題
- 1. 沒有黑色細線的UIView邊框
- 2. 具有圓角和邊框的UIView有錯誤的邊緣顏色
- 3. 沒有邊框顏色的梯形
- 4. LinearLayout按下時沒有邊框顏色
- 5. 邊框顏色變化沒有輸入
- 6. 界面生成器中的UIView邊框顏色不起作用?
- 7. 在圖像上沒有白色邊框
- 8. 迅速的UIView沒有一個成員叫中心
- 9. 顏色只有div的一個邊緣?
- 10. AVPlayerLayer沒有邊界到UIView的框架
- 11. 所有邊框的顏色不變(只有底部和右邊框的變化)
- 12. XCode 8.2.1 UIView沒有成員'加載請求'
- 13. blackberery彈出式窗口沒有黑色邊框顏色
- 14. 有沒有像MATLAB的OpenCV顏色條?
- 15. 顏色只有一個圓圈的地圖邊框gl js
- 16. 在應用邊框時獲取UIView上的白色邊框寬度和邊框顏色
- 17. 有沒有方法設置註釋文本的背景顏色和邊框?
- 18. 邊框顏色
- 19. 邊框顏色
- 20. #appcelerator文本框顏色和背景顏色沒有堅持
- 21. 兩個CSS類有不同的邊框顏色值,只有一個工作
- 22. 有沒有辦法改變標籤顏色和活動標籤邊框底部的顏色?
- 23. 我想要有背景顏色的右上邊框圖像
- 24. 沒有設置顏色的表面視圖邊框
- 25. 圖案圖像的邊框顏色
- 26. 有沒有辦法在CSS中設置默認的邊框顏色/大小?
- 27. 有一個表格邊框,但沒有單元格邊框
- 28. Flex按鈕,左邊一個顏色,右邊另一個顏色
- 29. jquery mobile,圖像周圍有一個小的黑色邊框
- 30. UITableViewCell中的UIView具有雙邊框
對,沒錯,這是錯的。但爲什麼我在Storyboard中沒有這個選項? –
默認情況下,這些選項在故事板中不可編輯。如果你想要的話,你可以添加一個'UIView擴展'來獲取故事板中的這些選項。檢查更新的答案。 –
謝謝!我用庫「材料」,它有默認的這一個,昨天我刪除了這個庫,它發生了)我認爲這是默認設置在IOS(我是新的在iOS編程) –