开发者

How to draw over the symbol on the tabbar?

开发者 https://www.devze.com 2023-03-20 17:35 出处:网络
I want to be able to draw the number of the date (1-31) over a calendar symbol I have placed on the tab-bar. I have a file called TabBarIcon which is a subclas开发者_如何学Cs of UITabBarItem. I am try

I want to be able to draw the number of the date (1-31) over a calendar symbol I have placed on the tab-bar. I have a file called TabBarIcon which is a subclas开发者_如何学Cs of UITabBarItem. I am trying to create a bitmap image that will overlay the symbol but will change according to the date.

Here is my code so far but I think i'll need to start again. As i'm quite confused to what is what now.

@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

Thanks


You could consider using the badgeValue, which displays the value in the upper-right corner of the item with a surrounding red oval.

// an example
self.navigationController.tabBarItem.badgeValue = @"7";

Note: The badge value is intended to be used for notification purposes. I am not sure how much that will fit your need.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号