2012-03-07 7 views
1

UIButtonを作成します。何らかの理由で、それは周りの白いギャップを(灰色の領域は、ボタンが中にあるのUIViewである)があります。UIButtonには隙間があります

enter image description here

コード:

UIView *photoView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [[UIScreen mainScreen] bounds].size.width, (THUMBNAIL_SIZE) + (PHOTO_VIEWER_OFFSET_COLUM_1 * 2))]; 
photoView.backgroundColor = [UIColor lightGrayColor]; 

UIScrollView *myScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, [[UIScreen mainScreen] bounds].size.width, photoView.frame.size.height)]; 
myScrollView.backgroundColor = [UIColor lightGrayColor]; 

UIButton *myButton = [UIButton buttonWithType:UIButtonTypeCustom]; 
myButton.frame = CGRectMake(0, 0, 50, 50); 
myButton.titleLabel.font = [UIFont fontWithName:labelFont size:16]; 
[myButton setTitle:@"X" forState:UIControlStateNormal]; 
[myButton setBackgroundImage:[UIImage imageNamed:@"add-report.png"] forState:UIControlStateNormal]; 
myButton.center = CGPointMake(((photoView.frame.size.width - myScrollView.frame.size.width)/2) + myScrollView.frame.size.width, photoView.frame.size.height/2); 

[photoView addSubview:myButton]; 
[self.view addSubview:photoView]; 

私は」白のバッファスペースをたくありませんそこには、しかし、私はそれを取り除く方法を把握することはできません。

任意のアイデア?

編集:私は背景色に変更しようとした場合:

myButton.backgroundColor = [UIColor orangeColor]; 

を私はこの効果を得る:

enter image description here

+0

灰色の枠がボタンの一部ですか?それはクリック可能ですか? – Saphrosit

+0

いいえ、申し訳ありません。灰色の部分はUIViewです。ボタンは緑と白の領域です。はい、白い部分はクリック可能です。 – Padin215

+0

バックグラウンドイメージを設定する代わりに '[myButton setImage:...]'を試してください – Saphrosit

答えて

0

それは白の背景もデフォルトを持っているテキストラベルであるかもしれませんか?

には、button.backgroundbutton.titleLabel.backgroundなどのすべての色を設定してみてください。

また、画像ビューを変更しようとしました。おそらく、期待通りに自動的に拡大/縮小されない場合があります。

button.imageView.contentMode = UIViewContentModeScaleToFill; 
+0

button.imageView.contentMode = UIViewContentModeScaleToFill;何もしなかった – Padin215

+0

clearColorについてはどうですか? – Mundi

+0

いいえ、明確な色で解決できませんでした。最初の投稿に画像を追加して、背景色の設定を示しました。クリアカラーでは、ボタンとスーパービューの背景色の間に空白が残っています – Padin215

関連する問題