UIButtonを作成します。何らかの理由で、それは周りの白いギャップを(灰色の領域は、ボタンが中にあるのUIViewである)があります。UIButtonには隙間があります
コード:
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];
を私はこの効果を得る:
灰色の枠がボタンの一部ですか?それはクリック可能ですか? – Saphrosit
いいえ、申し訳ありません。灰色の部分はUIViewです。ボタンは緑と白の領域です。はい、白い部分はクリック可能です。 – Padin215
バックグラウンドイメージを設定する代わりに '[myButton setImage:...]'を試してください – Saphrosit