Reputation: 840
I'm developing an application, which has textView
with bottom borders for each line, I can't find any answers on this question on google and on StackOverflow. So i decided i'll ask a question, i have this textview:
and i want it to look like this:
I'm doing it programmatically so please don't give me storyboard examples, Thank you
Upvotes: 2
Views: 437
Reputation: 619
You Can Use this code
-(void)setBorderView:(UITextField*)textField
{
UIView *borderView = [[UIView alloc]init];
borderView.backgroundColor = [UIColor clearColor];
CGRect frameRectEmail=textField.frame;
NSLogVariable(textField);
borderView.layer.borderWidth=1;
borderView.layer.borderColor=[customColor colorWithHexString:@"8c8b90"].CGColor;
borderView.layer.cornerRadius=5;
borderView.layer.masksToBounds=YES;
UIView *topBorder = [[UIView alloc]init];
topBorder.backgroundColor = [customColor colorWithHexString:@"1e1a36"];
CGRect frameRect=textField.frame;
frameRect.size.height=CGRectGetHeight(textField.frame)/1.5;
topBorder.frame = frameRect;
frameRectEmail.size.width=frameRect.size.width;
[borderView setFrame:frameRectEmail];
[_textFieldBackGroundView addSubview:borderView];
[_textFieldBackGroundView addSubview:topBorder];
[_textFieldBackGroundView addSubview:textField];
}
Upvotes: 0
Reputation: 3317
var textview:UITextView=UITextView()
for var i:Int = 20 ; i <= Int(textview.frame.size.height) ; i = i + 20 // set 20 you line distance .. change your chooice
{
let border = CALayer()
border.borderColor = UIColor.grayColor().CGColor
border.frame = CGRectMake(0, CGFloat(i), textview.frame.size.width*1.5 , 1.0)
border.borderWidth = 1.0
textview.layer.addSublayer(border)
textview.layer.masksToBounds = true
}
Upvotes: 1