// lazy Loading this input box private lazy var Textview:uitextview = { = uitextview () = Uifont.systemfontofsize ( - ) = uicolor.darkgraycolor ()
// working with the keyboard, setting the keyboard's vanishing mode Textview.keyboarddismissmode = Uiscrollviewkeyboarddismissmode.ondrag // set Spring effect True
returnTextView} () //lazy-Loading placeholder text PrivateLazy var Placehoderlabel:uilabel = UILabel (title:"Share New ...", Size: -, Color:UIColor.lightGrayColor ())//Set the input text box Privatefunc Settextview () {//Adding child controlsView.addsubview (textView) Textview.backgroundcolor=Uicolor.randomcolor ()
//Set Constraintstextview.snp_makeconstraints {(make), Voidinchmake.top.left.right.equalTo (Self.view) make.height.equalTo (view.bounds.height/3) } //Add placeholder textTextview.addsubview (Placehoderlabel)//Constraintsplacehoderlabel.snp_makeconstraints {(make), VoidinchMake.top.equalTo (textview.snp_top). Offset (8) Make.left.equalTo (textview.snp_left). Offset (5) } }
Swift Language Code add text input box and placeholder text