UIButton的使用
来源:互联网 发布:淘宝店铺男装推荐 编辑:程序博客网 时间:2024/06/07 00:56
本篇引荐别人的代码
UIButton *button=[UIButton buttonWithType:UIButtonTypeCustom];#pragma mark------设置位置和使能------- //设置大小位置 [button setFrame:CGRectMake(16, 30, 200, 200)]; //设置中心点 [button setCenter:self.view.center]; //设置使能 [button setEnabled:YES];#pragma mark-------设置背景颜色/图片------ //设置背景颜色/图片[ [button setBackgroundColor:[UIColor blueColor]];// [button setBackgroundImage:[UIImage imageNamed:@"www.png"] forState:UIControlStateNormal];// [button setBackgroundImage:[UIImage imageNamed:@"www.png"] forState:UIControlStateHighlighted];#pragma mark-------设置圆角/边框------- [button.layer setCornerRadius:50.0]; [button.layer setMasksToBounds:YES]; [button.layer setBorderWidth:10.0]; [button.layer setBorderColor:[[UIColor redColor] CGColor]];#pragma mark--------- 设置标题/字体/颜色/下划线---- NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:@"属性标题"]; NSRange strRange = {0,[attributedString length]}; [attributedString addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:strRange]; [button setAttributedTitle:attributedString forState:UIControlStateNormal];#pragma mark------设置标题和图标偏移------ [button setTitleEdgeInsets:UIEdgeInsetsMake(10, 10, 0, 0)]; [button setImageEdgeInsets:UIEdgeInsetsMake(0, 0, 10, 10)];#pragma mark------添加目标动作响应----- [button addTarget:self action:@selector(holdDownButtonTouchUpInside:) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:button];- (void)holdDownButtonTouchUpInside:(UIButton *)sender{ NSLog(@"按住按钮触摸到里面");}
阅读全文
0 0
- UIButton的使用
- UIButton的使用
- UIButton 使用的感受
- UIButton的使用
- UIButton的简单使用
- swift UIButton的使用
- swift UIButton的使用
- UIButton的使用细节
- UIButton的详细使用
- UIButton的使用
- UIButton的使用
- UIButton的使用
- UIButton 的使用
- UIButton的简单使用
- UIButton的使用
- UIButton的简单使用
- UIbutton 的 使用
- UIButton的基本使用
- leetcode 164. Maximum Gap
- 一文看懂中美AI产业布局,美国领衔芯片、算法、NLP领域
- 深度学习入门指北——从硬件到软件
- 如何用TensorFlow在安卓设备上实现深度学习推断
- Android 系统稳定性
- UIButton的使用
- idea在运行web项目时部署的位置(tomcat)
- SpringBoot 优点
- SQL中的case when then else end用法 .以及个人demo
- ansible playbook支持的atrributes
- Deep Learning based Recommender System: A Survey and New Perspectives (3)
- SpringBoot非官方教程 | 第十一篇:springboot集成swagger2,构建优雅的Restful API
- Ubuntu 下通过 ppa 安装 RabbitVCS
- JAVA基础-数组