自定义的button在ios7下可见,在ios6下不可见的解决办法
2013-12-19 17:53
267 查看
实现下面的button
1.先自定义button
UIButton *tiJiaoBtn=[UIButtonbuttonWithType:UIButtonTypeCustom];
tiJiaoBtn.frame=CGRectMake(148,0,
210, 54);
tiJiaoBtn.tag=2;
[tiJiaoBtn addTarget:selfaction:@selector(buttonOnClick:)forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:tiJiaoBtn];
2.给btn上面加上图片
UIImageView *tiJiaoImageView = [[UIImageViewalloc]
initWithFrame:CGRectMake(0,0,210,
54)];
tiJiaoImageView.image = [UIImageimageNamed:@"tijiaoBtn"];
[tiJiaoBtn addSubview:tiJiaoImageView];
[tiJiaoImageView release];
3.在btn的图片上加上文字
UILabel *tijiaoLabel=[[UILabelalloc]initWithFrame:CGRectMake(0,0,
210, 54)];
tijiaoLabel.textColor=[UIColor whiteColor];
tijiaoLabel.font=[UIFontsystemFontOfSize:22 ];
tijiaoLabel.textAlignment=UITextAlignmentCenter;
tijiaoLabel.text=@"提交";
[tiJiaoImageView addSubview:tijiaoLabel];
[tijiaoLabel release];
这样的实现以后发现在ios7下button可见。可是在ios6下却不可见了。解决办法:让label的背景为透明,即让tijiaoLabel的背景为透明颜色
tijiaoLabel.backgroundColor = [UIColorclearColor];
1.先自定义button
UIButton *tiJiaoBtn=[UIButtonbuttonWithType:UIButtonTypeCustom];
tiJiaoBtn.frame=CGRectMake(148,0,
210, 54);
tiJiaoBtn.tag=2;
[tiJiaoBtn addTarget:selfaction:@selector(buttonOnClick:)forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:tiJiaoBtn];
2.给btn上面加上图片
UIImageView *tiJiaoImageView = [[UIImageViewalloc]
initWithFrame:CGRectMake(0,0,210,
54)];
tiJiaoImageView.image = [UIImageimageNamed:@"tijiaoBtn"];
[tiJiaoBtn addSubview:tiJiaoImageView];
[tiJiaoImageView release];
3.在btn的图片上加上文字
UILabel *tijiaoLabel=[[UILabelalloc]initWithFrame:CGRectMake(0,0,
210, 54)];
tijiaoLabel.textColor=[UIColor whiteColor];
tijiaoLabel.font=[UIFontsystemFontOfSize:22 ];
tijiaoLabel.textAlignment=UITextAlignmentCenter;
tijiaoLabel.text=@"提交";
[tiJiaoImageView addSubview:tijiaoLabel];
[tijiaoLabel release];
这样的实现以后发现在ios7下button可见。可是在ios6下却不可见了。解决办法:让label的背景为透明,即让tijiaoLabel的背景为透明颜色
tijiaoLabel.backgroundColor = [UIColorclearColor];
相关文章推荐
- “textField.placeholder属性中的文字设置后在ios7下在textfield的中间。在ios6下字会往上偏”解决办法
- ios6到ios7视图的布局对绘图的影响及解决办法
- 关于iOS7之后自定义leftnavigationitem后手势无法响应问题的解决办法
- 自定义navigationControllerleftBar的ButtonItem导致系统不支持右滑返回解决办法
- 在springboot打包成jar后,无法读取自定义文件的解决办法
- iOS6和iOS7处理push不同之处,解决反复push,-(void) application: didReceiveRemoteNotification: fetchCompletionHandl
- Android开发中自定义ListView中存在ImageButton不响应ListItemClick单击事件详细d飞解决办法
- IOS7 UITableView一行滑动删除后 被删除行的下一行的点击事件将被忽略解决办法
- 在ssh框架下web.xml配置404和500错误代码,自定义不生效的解决办法。
- xcode5 ios7 64位 iphone5s引用第三方库报错的解决办法
- 自定义SiteMap后,SiteMap.SiteMapResolve事件处理程序不执行解决办法
- 关于解决自定义FloatingActionButton滑动行为(Behavior)只隐藏不出现的问题
- UINavigationController 自定义返回按钮导致返回手势失效解决办法
- ThinkPHP搜索条件是数组,加一条自定义Sql条件解决办法
- ThinkPHP搜索条件是数组,加一条自定义Sql条件解决办法
- 解决iOS7上自定义导航条UIBarButtonItem偏移问题
- Xcode5中ios7模拟器出现 Cannot find executable for CFBundle ... axbundle> (not loaded) 的解决办法
- wpf button的mouse(leftbutton)down/up,click事件不响应解决办法
- 解决android Button 自带阴影效果另一种办法
- 自定义View设置padding和wrap_content无效的解决办法