1
我希望能夠通過我已經放置在標籤欄上的日曆符號來繪製日期的編號(1-31)。我有一個名爲TabBarIcon的文件,它是UITabBarItem的一個子類。我正在嘗試創建一個覆蓋該符號的位圖圖像,但會根據日期進行更改。如何繪製標籤欄上的符號?
這是我的代碼,但我認爲我需要重新開始。因爲我現在很困惑。
@implementation TabBarIcon
CGContextRef CGBitmapContextCreate (
void *data,
size_t width,
size_t height,
size_t bitsPerComponent,
size_t bytesPerRow,
CGColorSpaceRef colorspace,
CGBitmapInfo bitmapInfo
);
-(void)drawRect:(CGRect)Rect{
CGImageRef context = UIGraphicsGetCurrentContext();
CGContextSetTextDrawingMode(context, kCGTextStroke);
CGContextSetRGBFillColor(context, 1.0, 0.0, 0.0, 1.0);
CGContextSelectFont(context, "Arial", 12.0, kCGEncodingMacRoman);
CGAffineTransform transform = CGAffineTransformMake(1.0, 0.0, 0.0, -1.0, 0.0, 0.0);
CGContextSetTextMatrix(context, transform);
CGContextShowTextAtPoint(context, 100.0, 100.0, "test", strlen("test"));
}
CGImageRef CGBitmapContextCreateImage(CGContextRef context);
@end
感謝
我可以定位徽章號碼並更改顏色或將它保留在紅色圓圈中。 – Dangermouse
是的。這裏你不走運。除了號碼之外,你不能改變任何東西。但我確定徽章號碼可以讓您的應用看起來很棒。 – EmptyStack
謝謝老兄 – Dangermouse