2011-03-16 13 views
0

私はちょうど私のビューに戻るボタンでUIToolbarを追加しました。このUIToolbarのタイトルをインターフェイスビルダに入れたいのですが、手動ではできないので、プログラムに追加する必要があります。 、私のビュークラスは、このようなものですしてくださいんUIToolbarのタイトルを追加するにはどうすればよいですか?

#import "AproposView.h" 


@implementation AproposView 

-(IBAction)backMainView{ 


    [self dismissModalViewControllerAnimated:YES]; 

} 

このバックボタンはUItoolbarである、だから、僕は事前にタイトル、THXを追加する必要が :)

+0

インターフェイスビルダーを試しましたか? – ThomasRS

答えて

1
#define UIColorFromRGB(rgbValue) [UIColor \ 
colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \ 
green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \ 
blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]  

UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 202, 23)]; 
label.textAlignment = UITextAlignmentCenter; 
label.backgroundColor = [UIColor clearColor]; 
label.shadowColor = UIColorFromRGB(0xe5e7eb); 
// label.shadowOffset = CGSizeMake(0, 1); 
    label.textColor = UIColorFromRGB(0x717880); 
    label.text = @"Edit Classes"; 
    label.font = [UIFont boldSystemFontOfSize:20.0]; 
    label.shadowColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5]; 
    label.shadowOffset = CGSizeMake(0, -1.0); 
    UIBarButtonItem *toolBarTitle = [[UIBarButtonItem alloc] initWithCustomView:label]; 
UIBarButtonItem *fixedSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:self action:nil]; 
toolBar.items = [NSArray arrayWithObjects:fixedSpace, toolBarTitle, fixedSpace, nil]; 
+0

あなたの答えはTHXですが、私はこれをどこに置くべきですか? – Malloc

+0

の 'viewDidLoad'の中であなたがそれを望むクラス – Andrew

+0

もしこの答えが助けられたら、それの隣にある緑色の矢印 – Andrew

0

の代わりに追加しますUIToolFieldにUILabelを追加して、UITextFieldをBar Button Itemとして追加し、必要なタイトルを設定し、そのUserInteractionを無効にします。 非常に簡単で簡単な技術。 Sanpshot Interface Builder

関連する問題