0
我在我的項目中使用了carbonkit。由於選項卡僅將文本/圖像視爲視圖,因此我將文本呈現爲圖像並將其放置在選項卡上。CarbonKit - 刷新/重新加載選項卡視圖
- (UIImage*) generateImageWithText:(UIImage*)img text:(NSString*)text
{
UIImageView *view = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 80, 80)];
UIImageView *imgView = [[UIImageView alloc]initWithImage:img];
imgView.backgroundColor = [UIColor clearColor];
imgView.frame = CGRectMake(15, 15, view.bounds.size.width-30, view.bounds.size.height-50);
imgView.contentMode = UIViewContentModeScaleAspectFit;
UILabel *lbl = [[UILabel alloc]initWithFrame:CGRectMake(0, imgView.frame.size.height + 20, view.bounds.size.width, 30)];
lbl.backgroundColor = [UIColor clearColor];
lbl.textAlignment = NSTextAlignmentCenter;
lbl.textColor = [UIColor whiteColor];
lbl.font = [UIFont systemFontOfSize:12];
lbl.text = text;
lbl.lineBreakMode = NSLineBreakByWordWrapping;
lbl.numberOfLines = 2;
[view addSubview:imgView];
[view addSubview:lbl];
UIGraphicsBeginImageContextWithOptions(view.bounds.size, NO, 0);
[view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *imageWithText = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return imageWithText;
}
我需要重新加載/刷新選項卡視圖(而不是標籤頁控制器)在一個按鈕的水龍頭。但是這些標籤是重疊的(新的標籤超過了以前的標籤)。我該如何解決這個問題?
沒有辦法從toolBar中刪除以前的圖像。 CarbonKit使用'[[CarbonTabSwipeNavigation alloc] initWithItems:items toolBar:self.toolBar delegate:self]'並且在重新加載或刷新tabview時設置視圖 –
,調用此方法initWithItems方法,此時刪除以前創建的對象。 –
我不能發送零項['[CarbonTabSwipeNavigation alloc] initWithItems:items toolBar:self.toolBar delegate:self]'它需要nonnull對象,所以它崩潰。我試圖通過項目數組與無圖像和'@「」文本(內'generateImageWithText'),但它什麼都沒做。 –