UIButton
プログラムで作成しました
togglebutton = [UIButton buttonWithType:UIButtonTypeCustom];
togglebutton.frame = CGRectMake(42, 15, 80, 21);
[togglebutton addTarget:self action:@selector(toggleview)
forControlEvents:UIControlEventTouchUpInside];
[togglebutton setImage:[UIImage imageNamed:@"squ.png"] forState:UIControlStateNormal];
[buttonView addSubview:togglebutton];
上の画像の右のボタンのように見えます。ここでの要件は、このボタンの選択領域が uibutton イメージよりも大きくなければならないことです。ユーザーが特定のボタンの近くの領域に触れることで、簡単にボタンをクリックできるようにします。
[togglebutton setImageEdgeInsets: UIEdgeInsetsMake( 0, -30, 0, -25)];
を設定しようとしましたimage inset
が、 になりimage irregular
ます。この問題を見てください。