天天看点

自定义TextView

class LANTextView{

            let TextView = UITextView ()

            let lable= UILabel ()

    //

    func setTextView(targetView: UIView ,TFrame: CGRect ){

            TextView . frame =TFrame

            TextView . backgroundColor = UIColor . yellowColor ()

            TextView . font = UIFont . systemFontOfSize ( 18 )

            TextView . backgroundColor = UIColor . yellowColor ()

            TextView . alwaysBounceVertical = true

            targetView. addSubview ( TextView )

        }

        // 设置初始字

        func placeHolder(holderText: String ,targetVC: UIViewController ,selector: Selector ){

            lable . frame . origin = CGPointMake ( 6 , 8 )

            lable . text =holderText as String

            lable . font = TextView . font

            lable . sizeToFit ()

            TextView . addSubview ( lable )

            NSNotificationCenter . defaultCenter (). addObserver (targetVC, selector: selector, name: UITextViewTextDidChangeNotification , object: nil )

        }

//        func textChange(){

//            if(TextView.text.){

//            lable.hidden=false

//            }

//         

//            lable.hidden=true

//       

//       

//        }

        //self.view.addSubview(LANTextView)

            }