我所做的UIButton
编程如何增加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
。请看这个问题。
您是如何选择这些插页以及您尝试了其他值的? – Wain
看看这个,试着改变按钮图像的视图模式,那么它应该与插图的工作和形象应该保持不变 - http://developer.apple.com/library/ios/#documentation/WindowsViews/Conceptual /ViewPG_iPhoneOS/WindowsandViews/WindowsandViews.html –
@Wain我设定按钮,图像尺寸的 –