---
title: "[转载]集成UIView"
author: "2014马年"
date: "2016-04-16T21:42:57Z"
tags: []
categories: ["移动开发"]
slug: "uiview"
draft: false
lastmod: "2016-04-16T21:42:57Z"
id: 2291833
url: "https://20142014.iteye.com/blog/2291833"
---

来源：

 

http://stackoverflow.com/a/27057168/2967461

 

 

```
class MyView: UIView {
    override init (frame : CGRect) {
        super.init(frame : frame)
        addBehavior()
    }

    convenience init () {
        self.init(frame:CGRect.zero)
    }

    required init(coder aDecoder: NSCoder) {
        fatalError("This class does not support NSCoding")
    }

    func addBehavior (){
        print("Add all the behavior here")
    }
}



let u = MyView(frame: CGRect.zero)
let v = MyView()
```