2011-08-01 5 views
0

私のアプリでは、必要に応じてユーザを助けるために現在のビューの上にポップアップするビューがあります。 問題はこれです:iPhone 4では、iPhone 3GSの上に小さなバンプが表示されている間は、そのビューの閉じるボタンがうまく見えます。なぜ私は考えていない。同じことがチェックボックスで起こります。コントロールはiPhone 4でよく見えますが、iPhone 3GSでは見えません。なぜですか?

ここにPicasaアルバムの写真があります(写真は2枚あり、iPhone 3GSと他のiPhone 4、閉じるボタンの上にあるバンプとiPhone 3GSの写真のチェックボックスがあります)。

https://picasaweb.google.com/103964563927969565521/StackoverflowPosts?authkey=Gv1sRgCKWHu6mKj4OS5AE

これは、閉じるボタンを作成するために使用するコードです:

// Close button 
    closeButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 

    float xCor = self.frame.size.width - kViewMargins - kCloseButtonWidth; 
    float yCor = y + ((self.frame.size.height - y)/2 - kCloseButtonHeight/2); 

    closeButton.frame = CGRectMake(xCor, 
            yCor, 
            kCloseButtonWidth, 
            kCloseButtonHeight); 

    [closeButton setTitle:kClose forState:UIControlStateNormal]; 
    [closeButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; 
    [[closeButton titleLabel] setFont:[UIFont boldSystemFontOfSize:kQuickTipTitleFontSize]]; 
    [closeButton setBackgroundImage:[UIImage imageNamed:@"close_button.png"] forState:UIControlStateNormal]; 
    [closeButton addTarget:self action: @selector (doneButtonClick) forControlEvents: UIControlEventTouchUpInside]; 
    [self addSubview:closeButton]; 

私が何をするか分からない、助けてください。

ありがとう、 Shaul。

+0

あなたはiphoneを作成していましたか? – nicks

+0

close_button.pngの外観を教えてください。 [email protected]もしあなたがいたら。 –

+0

ボタンの写真をアップロードしましたが、上記のリンクをご覧ください。 –

答えて

0

ええと、Jonが言ったように、RoundRectのデフォルト描画があなたのグラフィックの背後から出ているようです。むしろ、あなたのグラフィックスをいじりよりも、私はUIButtonTypeCustomに、ボタンの種類を変更することをお勧めします:

closeButton = [UIButton buttonWithType:UIButtonTypeCustom]; 

これが設定したグラフィックやテキストの外側NO UI要素とボタンを行います。

0

私はあなたのclose_button.pngファイルが見えないので推測していますが、あなたのclose_button.pngと作成しているボタンのサイズが異なり、見ているバンプがデフォルトです丸矩形の描画

+0

あなたは正しいです。私は2 pngのファイルを持っています。 1つは@ 2xのiPhone 4用です。これは、iPhone 3GSの画像が小さすぎるか何かを意味しますか?あなたはその問題を解決するためにどのように提案しますか? –

+0

close_button.pngファイルを測定し、kCloseButtonWidthとkCloseButtonHeightが正確に一致することを確認します。 –

0
closeButton = [UIButton buttonWithType:UIButtonTypeCustom]; 
UIImage* closeImage = [UIImage imageNamed:@"close_button.png"]; 
float xCor = self.frame.size.width - kViewMargins - kCloseButtonWidth; 
float yCor = y + ((self.frame.size.height - y)/2 - kCloseButtonHeight/2); 

closeButton.frame = CGRectMake(xCor, 
           yCor, 
           closeImage.size.width/2, 
           closeImage.Size.height/2); 

[closeButton setTitle:kClose forState:UIControlStateNormal]; 
[closeButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; 
[[closeButton titleLabel] setFont:[UIFont boldSystemFontOfSize:kQuickTipTitleFontSize]]; 
[closeButton setBackgroundImage:closeImage forState:UIControlStateNormal]; 
[closeButton addTarget:self action: @selector (doneButtonClick) forControlEvents: UIControlEventTouchUpInside]; 
[self addSubview:closeButton]; 
[closeButton release]; /// you must release the closeButton 
関連する問題