0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

viewに枠線をつけるSwift

Posted at

viewのあるほうこうにだけ枠線をつける方法

コピペで使える!!はず!

private func setupBorder(view:UIView) {
        let bottomBorder = CALayer()
        bottomBorder.frame = self.getCGrect(view: view,text:"buttom")
        bottomBorder.backgroundColor = 色設定
        view.layer.addSublayer(bottomBorder)
    }

private func getCGrect(view:UIView,text:String)->CGRect {
        switch text {
          case "bottom":
                return CGRect(x: 0, y: view.frame.height, width: view.frame.width, height: 1.0) 
          case "up":
                return CGRect(x: 0, y: 0, width: view.frame.width, height: 1.0) 
          case "right":
                return CGRect(x: view.frame.width, y: 0, width: 1.0, height: view.frame.height)
          case "left":
                return CGRect(x: 0, y: 0, width: 1.0, height: view.frame.height) 
          default:
            break
       }
    }
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?