티스토리 뷰

IOS - SWIFT

IOS SWIFT 뷰 그리기 (UIView)

tom7930 2016. 1. 27. 11:04

파란색 네모 그리기

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import UIKit
 
 
class ViewController: UIViewController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.drawNewView()
        // Do any additional setup after loading the view, typically from a nib.
    }
 
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
 
   
    func drawNewView(){
        let newView = UIView(frame: CGRect(x: 50, y: 50, width: 50, height: 50))
        newView.backgroundColor = UIColor.blueColor()
        self.view.addSubview(newView)
    }
    
}
cs



파란색 원 그리기

 

1
2
3
4
5
6
7
func drawNewView(){
        let newView = UIView(frame: CGRect(x: 50, y: 50, width: 50, height: 50))
        newView.backgroundColor = UIColor.blueColor()
        newView.layer.masksToBounds = true
        newView.layer.cornerRadius = 25 // 테두리 라운드 처리
        self.view.addSubview(newView)
    }
cs


 



댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday