0
私はアプリケーションを開発しています.の各行に下の罫線がありますが、GoogleとStackOverflowでこの質問に答えが見つかりません。 、私はプログラム的にそれをやっている各行のUITextViewの枠線
ので、私はストーリーボードの例を与えないでください:だから、私は質問をするだろうことを決めた、私はこのTextViewに持っている:
をし、私はそれは次のようになりたいですあなたは
私はアプリケーションを開発しています.の各行に下の罫線がありますが、GoogleとStackOverflowでこの質問に答えが見つかりません。 、私はプログラム的にそれをやっている各行のUITextViewの枠線
ので、私はストーリーボードの例を与えないでください:だから、私は質問をするだろうことを決めた、私はこのTextViewに持っている:
をし、私はそれは次のようになりたいですあなたは
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
}
あなたはこのコードを使用することができますありがとう
-(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];
}
ご確認ください。この1 - > https://でgithubの.com/mfoxstudio/MFUnderlinedTextView / –