您的位置:首页 > 移动开发 > IOS开发

iOS学习笔记-001.第一个程序初体验

2017-01-17 10:01 369 查看
第一个程序初体验
一模拟器

二弹框和log

三拨打电话和发短信

四界面跳转

五动画

第一个程序初体验

一、模拟器

command + shift + H 等同于 home 键
command + 1 大
command + 2 中
command + 3 小


二、弹框和log

@implementation ViewController
- (IBAction)fristClick:(id)sender {
//第一个点击效果
//1.打印log
NSLog(@"hello ios one");
//2.弹框
//2.1定义一个对话框
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"弹框" message:@"这是第一个弹框" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
//2.2显示出来
[alert show];
}




三、拨打电话和发短信

/*
打电话
*/
- (IBAction)btn_call:(id)sender {
//1 设置电话号码
NSURL * url = [NSURL URLWithString:@"tel://10086"];
//2 调用系统的拨号功能
[[UIApplication sharedApplication] openURL:url];
}

/*
发短信
*/
- (IBAction)btn_sms:(id)sender {
//1 设置电话号码
NSURL * url = [NSURL URLWithString:@"sms://10086"];
//2 写短信
[[UIApplication sharedApplication] openURL:url];
}




四、界面跳转





五、动画

@implementation ViewController
- (IBAction)btn_startAnimotion:(id)sender {
//集合存储图片
NSMutableArray * array1 = [[NSMutableArray alloc] init];
//1.现在图片先
UIImage *image1 = [UIImage imageNamed:@"bee1.png"];
UIImage *image2 = [UIImage imageNamed:@"bee2.png"];
UIImage *image3 = [UIImage imageNamed:@"bee3.png"];
UIImage *image4 = [UIImage imageNamed:@"bee4.png"];
UIImage *image5 = [UIImage imageNamed:@"bee5.png"];

[array1 addObject:image1];
[array1 addObject:image2];
[array1 addObject:image3];
[array1 addObject:image4];
[array1 addObject:image5];

//2 播放动画
//2.1 添加动画的图片到UIImageView中
_toImageView.animationImages = array1;

//2.2 设置动画的一些参数
_toImageView.animationDuration = 2; //2s
_toImageView.animationRepeatCount = 3;//循环3次

//2.3 播放动画
[_toImageView startAnimating];
}


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐