0
的删除过程中获得淡入要在TextView的线编程我已经实现下面的代码:绘制的线条文字
- (void)drawRect:(CGRect)rect{
CGContextRef ctx = UIGraphicsGetCurrentContext();
[super drawRect:rect];
CGSize textSize = [alpha sizeWithFont:[UIFont fontWithName:@"FreeHand575" size:28.0]
constrainedToSize:self.contentSize lineBreakMode:NSLineBreakByCharWrapping];
NSUInteger height = textSize.height;
textSize = [self.text sizeWithFont:self.font constrainedToSize:self.contentSize
lineBreakMode:NSLineBreakByCharWrapping];
NSUInteger contentHeight = (rect.size.height > textSize.height) ?
(NSUInteger)rect.size.height : textSize.height;
NSUInteger offset = height;
CGContextSetRGBStrokeColor(ctx, .8, .8, .8, 1);
for(int i=offset;i < contentHeight;i+=height) {
CGPoint lpoints[2] = { CGPointMake(0, i), CGPointMake(rect.size.width, i) };
CGContextStrokeLineSegments(ctx, lpoints, 2);
}}
它可以正常使用。但是当用户从textview中删除文本并且某个地方画出的线条也会被删除或淡入时出现问题。
我无法找到问题。如果有人有一些想法,请帮助我。
在此先感谢
你有没有试过写这行[super drawRect:rect];在最后? –
@hussainShabbir是的我试过了,但没有解决问题 –