button中的ps调整文字间距的间距怎么调

iOS 问题:如何同时设置button几个状态的title
[button1 setTitle:@"title" forState:UIControlStateNormal];
关于这个方法所用的state 是一个位枚举,所以我想当然的认为 同时设置 选中与普通状态的title应该是这样:
[button1 setTitle:@"title" forState:UIControlStateNormal + UIControlStateSelected];
可是界面上4个button 只有一个被选中的button 文字改了。求大神告知哪里出问题了。 -
如何同时设置button几个状态的title
[button1 setTitle:@"title" forState:UIControlStateNormal];
关于这个方法所用的state 是一个位枚举,所以我想当然的认为 同时设置 选中与普通状态的title应该是这样:
[button1 setTitle:@"title" forState:UIControlStateNormal + UIControlStateSelected];
可是界面上4个button 只有一个被选中的button 文字改了。求大神告知哪里出问题了。
共有 2 个回答
UIControlStateNormal + UIControlStateSelected,从枚举类型的角度来说,变成了1,也就是UIControlStateSelected。因为UIControlStateNormal等于0,UIControlStateSelected等于1。0+1=1(UIControlStateSelected)。
登录后方可回复
@code4app : 是我搞错了。。。 开始用的 UIControlStateNormal & UIControlStateSelected 没有作用。
应该是 UIControlStateNormal|UIControlStateSelected
登录后方可回复
登录后方可回答
耗时 0.0776 秒| 漏洞检测 |
| 隐藏捆绑 |
iOS - UIButton(UIEdgeInsets)/设置button上的文字和图片上下垂直居中对齐
UIEdgeInsets [objc] typedef struct UIEdgeInsets { CGFloat top, left, bottom, // specify amount to inset (positive) for each of the edges. values can be negative to outset } UIEdgeI 在UIButton中有三个对EdgeInsets的设置:ContentE
UIEdgeInsets
typedef struct UIEdgeInsets { &
& & CGFloat top, left, bottom, &// specify amount to inset (positive) for each of the edges. values can be negative to 'outset' &
} UIEdgeI &
在中有三个对EdgeInsets的:ContentEdgeInsets、titleEdgeInsets、imageEdgeInsets
@property(nonatomic) & & & & &UIEdgeInsets contentEdgeInsets UI_APPEARANCE_SELECTOR; // default is UIEdgeInsetsZero &
@property(nonatomic) & & & & &UIEdgeInsets titleEdgeI & & & & & & & &// default is UIEdgeInsetsZero &
@property(nonatomic) & & & & &BOOL & & & & reversesTitleShadowWhenH // default is NO. if YES, shadow reverses to shift between engrave and emboss appearance &
@property(nonatomic) & & & & &UIEdgeInsets imageEdgeI & & & & & & & &// default is UIEdgeInsetsZero &
UIEdgeInsetsMake
里面的四个参数表示距离上边界、左边界、下边界、右边界的距离,默认都为零,title/image在n的正中央
UIKIT_STATIC_INLINE UIEdgeInsets UIEdgeInsetsMake(CGFloat top, CGFloat left, CGFloat bottom, CGFloat right) { &
& & UIEdgeInsets insets = {top, left, bottom, right}; &
&self.view.backgroundColor = [UIColor blackColor]; &
*n = [UIButton buttonWithType:UIButtonTypeCustom];//button的类型 &
& & button.frame = CGRectMake(100, 100,90, 90);//button的frame &
& &button.backgroundColor = [UIColor cyanColor];//button的背景颜色 &
// & &[button setBackgroundImage:[UIImage imageNamed:@&man_64.png&] forState:UIControlStateNormal]; &
// & &在UIButton中有三个对EdgeInsets的:ContentEdgeInsets、titleEdgeInsets、imageEdgeInsets &
& & [button setImage:[UIImage imageNamed:@&IconHome@2x.png&] forState:UIControlStateNormal];//给button添加image &
& & button.imageEdgeInsets = UIEdgeInsetsMake(5,13,21,button.titleLabel.bounds.size.width);//设置image在button上的位置(上top,左left,下bottom,右right)这里可以写负值,对上写-5,那么image就象上移动5个像素 &
& & [button setTitle:@&首页& forState:UIControlStateNormal];//设置button的title &
& & button.titleLabel.font = [UIFont systemFontOfSize:16];//title字体大小 &
& & button.titleLabel.textAlignment = NSTextAlignmentC//设置title的字体居中 &
& & [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];//设置title在一般情况下为白色字体 &
& & [button setTitleColor:[UIColor grayColor] forState:UIControlStateHighlighted];//设置title在button被选中情况下为灰色字体 &
& & &button.titleEdgeInsets = UIEdgeInsetsMake(71, -button.titleLabel.bounds.size.width-50, 0, 0);//设置title在button上的位置(上top,左left,下bottom,右right) &
// & &[button setContentEdgeInsets:UIEdgeInsetsMake(70, 0, 0, 0)];// &
// & button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentC//设置button的内容横向居中。。设置content是title和image一起变化 &
& & [button addTarget:self action:@selector(tap) forControlEvents:UIControlEventTouchUpInside]; &
& & [self.view addSubview:button]; &
//button相应的事件 &
-(void)tap { &
& & NSLog(@&tap a button&); &
& & UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@&hello& message:@&willingseal& delegate:self cancelButtonTitle:@&ok& otherButtonTitles: nil nil]; &
& & [alertView show]; &
(责任编辑:幽灵学院)
------分隔线----------------------------
单例模式是iOS常用设计模式中的一种。单例设计模式的作用是使得这个类的一个对象成为...
ios9中 UIStackView的使用by 伍雪颖 UIStackView可以垂直或水平排布多个subview, 自动...
之前项目中使用到了归档的技术,也用到了MJExtension 但是问题是,这个公共库遇到了无...
这是大家熟悉的开发过程中可能遇到的问题 这是提交源码到appStore不支持64位设备的提...
从摄像头或者是从相册中读取图片,需要通过UIImagePickerController类来实现,在使用U...
直接代码: 类 // ACETelPrompt.h #import @interface ACETelPrompt : NSObject typed...
admin@1744.cc
工作日:9:00-21:00
周 六:9:00-18:00
&&扫一扫关注幽灵学院
广告服务:QQ:

我要回帖

更多关于 ps中文字间距怎么调 的文章

 

随机推荐