I need to draw a background image or set the hue color in the navigation bar, but I also need the option to display the navigation bar as usual. I am currently using a category for support. If my application does not specify a background image, what can I do instead to make the drawRect method normally execute?
those. -
@implementation UINavigationBar (UINavigationBarCategory) - (void)drawRect:(CGRect)rect { if(hasImage){ UIImage *img = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://myimageurl.com/img.jpg"]]]; [img drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)]; }else{ ?????? } } @end
- , , . , Googling , UINavigationBar. , . .
myUIImageView.userInteractionEnabled = ; [myNavController.navigationBar addSubview: myUIImageView]; [myNavController.navigationBar sendSubviewToBack: myUIImageView];
/ , drawRect , swizzle . .
UINavigationBar, drawRect:, [super drawRect:rect], .
drawRect:
[super drawRect:rect]
, , UINavigationBar .
, , "" , . , , super, .
super
"" : http://cocoawithlove.com/2008/03/supersequent-implementation.html
( : C?)
Source: https://habr.com/ru/post/1746437/More articles:Очень большая база данных, очень маленькая часть, которая больше всего извлекается в реальном времени - performanceWhat is Dublin and how does it relate to WCF? - .netMicrosoft Codename? - iisbinding the current wpf datagrid element - c #ASP.NET: how to get the same validator control both on client side and server side - validationcheck if form group is visible - actionscriptПолиморфизм Java - выбор правильного метода на основе подтипа - javaDoes Wifi have any form of direct error correction? - cryptographyqApply jQuery dialogs - javascriptLINQ, Left Join, Only Get where null in the join table - c #All Articles