1. 程式人生 > >iOS小技巧-UITextFiled/UITextView設定系統圓角邊框

iOS小技巧-UITextFiled/UITextView設定系統圓角邊框

iOS中單行輸入一般使用UITextField,而多行輸入一般使用UITextView,但是,UITextField設定圓角邊框可以使用

textField.borderStyle = UITextBorderStyleRoundedRect;

直接進行設定,而UITextView卻沒有提供類似的方法,所以可以通過layer做出類似的邊框樣式效果。
textView.layer.borderColor = [[UIColor colorWithRed:199/255.0 green:199/255.0 blue:199/255.0 alpha:1] CGColor];
textView.layer.borderWidth = 0.5f;
textView.layer.cornerRadius = 5.0f;
資料僅供參考,效果圖如下: