我想在我的應用程序中使用很多像這樣的酒吧(我不知道如何命名它:包含「早期秀」「48小時」的酒吧)。在UINavigationBar下面添加一個小酒吧
有沒有簡單的方法來創建這樣的東西?什麼是基本對象使用? 謝謝。
bar from CBS app http://a1.phobos.apple.com/us/r1000/056/Purple/38/9f/8a/mzl.bqhasrjw.320x480-75.jpg
我想在我的應用程序中使用很多像這樣的酒吧(我不知道如何命名它:包含「早期秀」「48小時」的酒吧)。在UINavigationBar下面添加一個小酒吧
有沒有簡單的方法來創建這樣的東西?什麼是基本對象使用? 謝謝。
bar from CBS app http://a1.phobos.apple.com/us/r1000/056/Purple/38/9f/8a/mzl.bqhasrjw.320x480-75.jpg
AKAIK,沒有什麼,這是否適合您的SDK。但是,可以使用UIScroll視圖以及一些自定義UIButons和漂亮的蒙版圖像來重現您在屏幕截圖中顯示的內容。
.H
IBOutlet UIScrollView *scrollView;
@property (nonatomic , retain) IBOutlet UIScrollView *scrollView;
-(void)AppleVijayAtFacebookDotCom:(id)sender;
-(void)createMenuWithButtonSize:(CGSize)buttonSize withOffset:(CGFloat)offset noOfButtons:(int)totalNoOfButtons;
.M
@synthesize scrollView;
-(void)AppleVijayAtFacebookDotCom:(id)sender{
NSLog(@"AppleVijayAtFacebookDotCom called");
UIButton *button=(UIButton *)sender;
if (button.tag == 0) {
NSLog(@"hey have clicked first button, this is my tag : %i \n\n",button.tag);
}
else if (button.tag == 1) {
NSLog(@"hey have clicked second button, this is my tag : %i \n\n",button.tag);
}
// ......like this
NSLog(@"button clicked is : %iBut \n\n",button.tag);
}
-(void)createMenuWithButtonSize:(CGSize)buttonSize withOffset:(CGFloat)offset noOfButtons:(int)totalNoOfButtons{
for (int i = 0; i < totalNoOfButtons; i++) {
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button addTarget:self action:@selector(AppleVijayAtFacebookDotCom:) forControlEvents:UIControlEventTouchUpInside];
//[button1 setImage:[UIImage imageNamed:@"Button.png"] forState:UIControlStateNormal];//with image
//OR
[button setTitle:[NSString stringWithFormat:@"%iBut",i] forState:UIControlStateNormal];//with title
button.frame = CGRectMake(i*(offset+buttonSize.width), 8.0, buttonSize.width, buttonSize.height);
button.clipsToBounds = YES;
button.showsTouchWhenHighlighted=YES;
button.layer.cornerRadius = 10;//half of the width
button.layer.borderColor=[UIColor redColor].CGColor;
button.layer.backgroundColor=[UIColor blackColor].CGColor;
button.layer.borderWidth=2.0f;
button.tag=i;
[self.scrollView addSubview:button];
}
self.scrollView.contentSize=CGSizeMake((buttonSize.width + offset) * totalNoOfButtons, buttonSize.height);
//self.navigationItem.titleView=self.scrollView;//if u have navigationcontroller then enable this line
}
不要忘記了滾動連接在Interface Builder
雖然在IB創建滾動視圖確保你的scrollView高度是44.這是默認導航bar.so它會看起來不錯。
in viewDidLoad call
[self createMenuWithButtonSize:CGSizeMake(70.0, 30.0) withOffset:20.0f noOfButtons:30];
輸出
謝謝,我與它的工作 – lefakir 2010-03-23 10:11:55
那麼,如何接受這個作爲正確回答你的問題?謝謝。 – 2010-03-23 12:56:26