我正在创建一个应用程序,并希望使用UITextView和子类UITextView来概述文本。使用UILabel可以通过下面的例子来完成,但是UITextView不提供drawTextinRect。有没有人对如何在UITextView中勾勒出文本轮廓有什么建议?
- (void)drawTextInRect:(CGRect)rect
{
CGSize shadowOffset = self.shadowOffset;
UIColor *textColor = self.textColor;
CGContextRef context = UIGraphicsGetCurrentContext();
self.shadowOffset = CGSizeMake(0.0, 0.0);
CGContextSetLineWidth(context, [[self font] pointSize]/8.0);
CGContextSetTextDrawingMode(context, kCGTextStroke);
self.textColor = [UIColor blackColor];
[super drawTextInRect:rect];
CGContextSetTextDrawingMode(context, kCGTextFill);
self.textColor = textColor;
self.shadowOffset = CGSizeMake(0, 0);
[super drawTextInRect:rect];
self.shadowOffset = shadowOffset;
}发布于 2012-07-13 14:22:32
您可以实现- (void)drawRect:(CGRect)rect,因为UITextView是UIView的子类,并在其中实现您的自定义绘图。
https://stackoverflow.com/questions/11464318
复制相似问题