我正在开发我的应用程序的新版本,并且我正在尝试替换已弃用的消息,但我无法通过这个消息.
我无法弄清楚为什么drawInRect:withAttributes不起作用.drawInRect:withFont:lineBreakMode:alignment发送消息时代码正确显示,但drawInRect:withAttributes发送时不起作用.
我使用相同的矩形和字体,我相信是相同的文本样式.常量只是将rect定位在图像下方,但我对两个调用使用相同的rect,所以我确定矩形是正确的.
(注意下面使用的bs.name是一个NSString对象)
CGRect textRect = CGRectMake(fCol*kRVCiPadAlbumColumnWidth,
kRVCiPadAlbumColumnWidth-kRVCiPadTextLabelYOffset,
kRVCiPadAlbumColumnWidth,
kRVCiPadTextLabelHeight);
NSMutableParagraphStyle *textStyle = [[NSMutableParagraphStyle defaultParagraphStyle] mutableCopy];
textStyle.lineBreakMode = NSLineBreakByWordWrapping;
textStyle.alignment = NSTextAlignmentCenter;
UIFont *textFont = [UIFont systemFontOfSize:16];
Run Code Online (Sandbox Code Playgroud)
使用上面的变量,这不起作用(屏幕上没有任何内容)
[bs.name drawInRect:textRect
withAttributes:@{NSFontAttributeName:textFont,
NSParagraphStyleAttributeName:textStyle}];
Run Code Online (Sandbox Code Playgroud)
这可以使用上面相同的变量工作(在屏幕上正确绘制字符串)
[bs.name drawInRect:textRect
withFont:textFont
lineBreakMode:NSLineBreakByWordWrapping
alignment:NSTextAlignmentCenter];
Run Code Online (Sandbox Code Playgroud)
任何援助都会很棒.谢谢.
我知道 ios-charts 不支持标签旋转。任何要求此功能的问题都会立即关闭,但这是一个非常基本的功能。我已经看到人们在 MPAndroidChart(这是基于它的)中发布有关如何执行此操作的帖子,但这些解决方案似乎是特定于 Android 的。有谁知道在 iOS 图表中为条形图获得 45 度或 90 度标签旋转的方法吗?
如何将NSString旋转到一定程度?当我与图像一起画一个字符串.
我提到这个问题用NSString drawInRect绘制旋转文本,但我的Ellipse消失了.
//Add text to UIImage
-(UIImage *)addMoodFound:(int)moodFoundCount andMoodColor:(CGColorRef)mColour
{
float scaleFactor = [[UIScreen mainScreen] scale];
UIGraphicsBeginImageContextWithOptions(CGSizeMake(36, 36), NO,scaleFactor);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSaveGState(context);
//CGContextSetRGBFillColor(context, kCGAggressiveColor);
CGContextSetFillColorWithColor(context,mColour);
CGContextFillEllipseInRect(context, CGRectMake(0, 0, 36, 36));
CGContextSetRGBFillColor(context, 250, 250, 250, 1);
//nsstring missing after adding this 3 line
CGAffineTransform transform1 = CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(65));
CGContextConcatCTM(context, transform1);
CGContextTranslateCTM(context, 36, 0);
Run Code Online (Sandbox Code Playgroud)
////////////////////////////////////////////////
[[NSString stringWithFormat:@"%d",moodFoundCount ] drawInRect : CGRectMake(0, 7, 36, 18)
withFont : [UIFont fontWithName:monR size:17]
lineBreakMode : NSLineBreakByTruncatingTail
alignment : NSTextAlignmentCenter ];
CGContextRestoreGState(context);
UIImage …Run Code Online (Sandbox Code Playgroud)