searchcontroller,roundedcorners不工作
问题描述:
searchcontroller,roundedcorners不工作
这种观点的顺序是这样的
-View Controller
-Fake shadow view
-Container view
-Search Bar
在正常状态下,roundedcorner工作正常,但是当我点击它,有一些影子。当我键入它的东西只是角度的rectengular
答
试试这个IBDesignable类和故事板
import Foundation
@IBDesignable class customView: UIView {
@IBInspectable var cornerRadius: CGFloat = 0 {
didSet {
layer.cornerRadius = cornerRadius
}
}
@IBInspectable var borderWidth: CGFloat = 0 {
didSet {
layer.borderWidth = borderWidth
}
}
@IBInspectable var borderColor: UIColor = UIColor.gray {
didSet {
layer.borderColor = borderColor.cgColor
}
}
@IBInspectable var shadowColor: UIColor = UIColor.gray {
didSet {
layer.shadowColor = shadowColor.cgColor
}
}
@IBInspectable var shadowOpacity: Float = 1.0 {
didSet {
layer.shadowOpacity = shadowOpacity
}
}
@IBInspectable var shadowRadius: CGFloat = 1.0 {
didSet {
layer.shadowRadius = shadowRadius
}
}
@IBInspectable var masksToBounds: Bool = true {
didSet {
layer.masksToBounds = masksToBounds
}
}
@IBInspectable var shadowOffset: CGSize = CGSize(width: 12, height: 12) {
didSet {
layer.shadowOffset = shadowOffset
}
}
}
+0
它在UIViewController类中工作吗? – KKRocks
+0
将此类应用于您的containerview视图并从storyboard将属性分配给视图 –
https://iosdevcenters.blogspot.com/2016/07/hacking-uisearchbar-给圆角in-swift.html –