iOS开发 UIButton的创建与使用

 时间:2024-10-15 04:34:00

1、创建工程项目和视图控制器 1、创建一个Sing View Application工程项目; 2、为项目命名,生成工程文件。

iOS开发 UIButton的创建与使用

3、设置位置和使能 [button setFrame:CGRectMake(16, 30, 200, 50)]; [button setCenter:self.view.center]; [button setEnabled:YES];

iOS开发 UIButton的创建与使用

5、设置圆角/边框 [button.layer setCornerRadius:5.0]; [button.layer setMasksToBounds:YES]; [button.layer setBorderWidth:3.0]; [button.layer setBorderColor:[[UIColor redColor] CGColor]];

iOS开发 UIButton的创建与使用

7、设置图标 默认30*30大小的。@2x为60*60;@3x为90*90的。

iOS开发 UIButton的创建与使用

9、添加目标动作响应 [button addTarget:self action:@selector(holdDown蚱澄堆别ButtonTouchUpInside:) forControlEvents:UIControlEventTouchUpInside];- (void)holdDownButtonTouchUpInside:(UIButton *)sender{ NSLog(@"按住按钮触摸到里面");}

iOS开发 UIButton的创建与使用
  • Mac自带FTP工具用法
  • IOS开发入门教程 第一个IOS应用程序(xcode10.1)
  • MacOS中Maven环境配置
  • Mac系统如何编辑hosts文件
  • mac怎么安装vscode?
  • 热门搜索
    轻蔑的反义词是什么 养兔子要注意什么 trust什么意思 8月23日是什么节日 蜗牛爱吃什么 光彩夺目是什么意思 健康管理师有什么用 巴西木的养殖方法和注意事项 什么是丹霞地貌 大飞机是什么意思