在自定义UIButton上更改触摸区域,并在横向模式下更改图像和标题 [英] Touch area changing on custom UIButton with image and title on landscape mode

查看:108
本文介绍了在自定义UIButton上更改触摸区域,并在横向模式下更改图像和标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建一个类似于iPhone上的图标的按钮,并带有图像和标题栏.我正在横向模式下工作. 我在IB上有一个带有图像和标题的自定义按钮,并且在代码中使用了以下方法:

I'm trying to build a button that looks like the icons on the iphone , with an image and a title bellow.I'm working in landscape mode. I have a custom button on the IB with image and title and inside the code I use the methods :


[aButton setTitleEdgeInsets:UIEdgeInsetsMake(60.0, -50.0, 0.0, 0.0)];
[aButton setImageEdgeInsets:UIEdgeInsetsMake(-10.0, 29.0, 0.0, 0.0)];

我的问题是,对触摸事件做出反应的区域很小,并且位于按钮的左上方,另一个问题是,如果更改按钮的大小,则必须再次手动计算这两个功能的值. 有什么简单的方法吗?如果没有,我该如何固定触摸区域? 谢谢 吉拉德

my problem is that the area that react to the touch events is very small and is on the top left of the button , another problem is that if I change my button size I have to calculate again manually the values for these 2 functions. Is there any easy way to do it?and if not how can I fix the touch area? thanks Gilad

推荐答案

好吧,我刚刚删除了NIB文件并创建了一个新文件,一切正常.

well , I just removed the NIB file and created a new one and everything works just fine

这篇关于在自定义UIButton上更改触摸区域,并在横向模式下更改图像和标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆