button点击效果变化与addSubview到哪里有关系
2014-12-14 14:10
162 查看
今天在做项目的过程中,发现,button 的点击效果的决定是由是否添加的是不是self.view上有关。
btn_body = [UIButton
buttonWithType:UIButtonTypeSystem];
btn_body.frame =
CGRectMake(45,
102, 230,
153);
[btn_body
setBackgroundImage:[UIImage
imageNamed:@"body_b1"]
forState:UIControlStateNormal];
[img_portrait
addSubview:btn_body];
这样,btn_body被点击的时候,将不会显示出被点击的效果。
如果是
btn_body = [UIButton
buttonWithType:UIButtonTypeSystem];
btn_body.frame =
CGRectMake(45,
102, 230,
153);
[btn_body
setBackgroundImage:[UIImage
imageNamed:@"body_b1"]
forState:UIControlStateNormal];
[self.view addSubview:btn_body];
这样,btn_body被点击的时候,会显示出被点击的效果。
目前与其他的暂时无关,比如
UIButtonType,isenable,userinterface等等其他属性。之前也 在项目开发的过程中碰到了,用xib拖的button一直是可以出现被点击的时候显示出点击效果的,因为拖到xib中的button是addsubview到self.view上面的。
btn_body = [UIButton
buttonWithType:UIButtonTypeSystem];
btn_body.frame =
CGRectMake(45,
102, 230,
153);
[btn_body
setBackgroundImage:[UIImage
imageNamed:@"body_b1"]
forState:UIControlStateNormal];
[img_portrait
addSubview:btn_body];
这样,btn_body被点击的时候,将不会显示出被点击的效果。
如果是
btn_body = [UIButton
buttonWithType:UIButtonTypeSystem];
btn_body.frame =
CGRectMake(45,
102, 230,
153);
[btn_body
setBackgroundImage:[UIImage
imageNamed:@"body_b1"]
forState:UIControlStateNormal];
[self.view addSubview:btn_body];
这样,btn_body被点击的时候,会显示出被点击的效果。
目前与其他的暂时无关,比如
UIButtonType,isenable,userinterface等等其他属性。之前也 在项目开发的过程中碰到了,用xib拖的button一直是可以出现被点击的时候显示出点击效果的,因为拖到xib中的button是addsubview到self.view上面的。
相关文章推荐
- textview中点击效果实现,比如点击textview中实现图片和文字的颜色变化(类似于button)
- 自定义Button被点击的颜色变化效果
- android Button 点击背景与文字颜色变化效果
- 如何让LinearLayout也有类似Button的点击效果?
- Android开发自定义圆角带点击效果的Button
- 自定义Button点击效果
- Android 文字和按钮Button点击效果的(selector使用)直接用
- 关于button按钮设置background属性后,点击效果失效的解决办法。(当点击的时候显示阴影)
- 用TextView实现button点击效果
- Android之实现TextView控件圆角以及Button点击、焦点效果
- ImageButton设置 android:background添加点击效果
- Android中的Button自定义点击效果之改变点击时按钮的颜色
- [Android] ImageButton | Button | TextView 点击和触摸效果实现
- 点击button,button背景图片变化
- 点击button 发亮效果 设置
- android问题之Button自定义样式selector后,点击无效果
- imagebutton 设置点击和按压效果
- 设置Button背景渐变效果和点击效果
- android selector设置button点击效果(具体)以及常见问题
- android selector 背景选择器的使用, button (未点击,点击,选中保持状态)效果实现