本项目是取自传智播客的教学项目,加入笔者的修改和润饰。
1. 项目名称:按钮操作
2. 项目截图展示
3. 项目功能
- 点击按钮,切换按钮状态
- 上下左右移动按钮
- 放大,缩小按钮
- 左右旋转按钮
4. 项目代码
#import "ViewController.h"
//设置按钮移动速度
#define KMovingDelta 20
//设置按钮标签枚举值
typedef enum{
kMovingDirTop = 10,
kMovingDirBottom,
kMovingDirLeft,
kMovingDirRight,
} kMovingDir;
@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIButton *iconButton;
@end
@implementation ViewController
//加载完成被调用
- (void) viewDidLoad{
//调用父类的实现方法
[super viewDidLoad];
UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(110, 100,