【发布时间】:2012-05-12 08:53:13
【问题描述】:
我想将带有以编程方式绘制的线条作为背景图案的 UIView 添加到 UITextView 字段(根据 UITextView 中的拼写错误,textview 字段应该看起来有点像具有适当行高的横格纸)。
下面是 UIView 绘制的线条代码当前的样子,带有一些固定值。
for (int i = 0; i < 4; i++) {
CGContextMoveToPoint(context, 80.0, (215.0+i*21.0));
CGContextAddLineToPoint(context, 310.0, (215.0+i*21.0));
}
CGContextSetShouldAntialias(context, false);
CGContextStrokePath(context);
我发现实际上可以将背景图像作为 UIColor 分配给 UITextview(在本例中为“viewLogNote”)。
[[self viewLogNote]setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed: @"UITextField_Background"]]];
有没有办法对自定义绘图做类似的事情?
【问题讨论】:
-
你也许可以从这里抢救一些东西。 stackoverflow.com/questions/759658/uitextview-background-image
标签: objective-c ios uiview uitextview