-2
請任何人都可以提供一個圖像在X軸上反覆添加的想法。 在此先感謝我們如何重複添加工具欄中的圖像?
請任何人都可以提供一個圖像在X軸上反覆添加的想法。 在此先感謝我們如何重複添加工具欄中的圖像?
喜這裏是代碼按類別添加圖片到UIToolBar ....
.h文件中:
#import <UIKit/UIKit.h>
@interface UIToolbar (AddtitionalFuntionality)
+(void)setToolbarBack:(NSString*)bgFilename toolbar:(UIToolbar*)toolbar;
@end
.m文件:
#import "UIToolbar+AddtitionalFuntionality.h"
@implementation UIToolbar (AddtitionalFuntionality)
+(void)setToolbarBack:(NSString*)bgFilename toolbar:(UIToolbar*)bottombar {
// Add Custom Toolbar
UIImageView *iv = [[UIImageView alloc] initWithImage:[UIImage imageNamed:bgFilename]];
iv.frame = CGRectMake(0, 0, bottombar.frame.size.width, bottombar.frame.size.height);
iv.autoresizingMask = UIViewAutoresizingFlexibleWidth;
// Add the tab bar controller's view to the window and display.
if([[[UIDevice currentDevice] systemVersion] intValue] >= 5)
[bottombar insertSubview:iv atIndex:1]; // iOS5 atIndex:1
else
[bottombar insertSubview:iv atIndex:0]; // iOS4 atIndex:0
bottombar.backgroundColor = [UIColor clearColor];
}
@end
該調用語句將...
[UIToolbar setToolbarBack:@"tool-bar.png" toolbar:toolBarTop];
類的源代碼Here
鏈接到博客:Site
喜用類文件添加圖像.... – Spynet
細說你正在嘗試做 – Ranjit
我有一個小的JPG圖像,並重復添加工具欄背景 –