指定したUIViewに対して、画面サイズいっぱいに罫線(上・下)を引くExtensionです。
ランドスケープにした場合にも端まで引かれている必要があるため、スクリーンの縦・横サイズを取得しています。
extension UIView {
func drawTopBorderMax(borderWidth: CGFloat, borderColor: UIColor) {
var width = UIScreen.mainScreen().bounds.size.width
if width < UIScreen.mainScreen().bounds.size.height {
width = UIScreen.mainScreen().bounds.size.height
}
var border = CALayer(layer: self.layer)
border.frame = CGRectMake(0.0, 0.0, width, borderWidth)
border.backgroundColor = borderColor.CGColor
self.layer.addSublayer(border)
}
func drawButtomBorderMax(borderWidth: CGFloat, borderColor: UIColor) {
var width = UIScreen.mainScreen().bounds.size.width
if width < UIScreen.mainScreen().bounds.size.height {
width = UIScreen.mainScreen().bounds.size.height
}
var border = CALayer(layer: self.layer)
border.frame = CGRectMake(0.0, self.frame.size.height, width, borderWidth)
border.backgroundColor = borderColor.CGColor
self.layer.addSublayer(border)
}
}


