第一个iOS应用程序开发
来源:互联网 发布:淘宝商家信用卡费率 编辑:程序博客网 时间:2024/06/05 09:32
//// ViewController.m// ZhiTouZi//// Created by mac on 15-10-28.// Copyright (c) 2015年 mac. All rights reserved.//#import "ViewController.h"@interface ViewController ()@end@implementation ViewController{ UILabel *leftDice; UILabel *rightDice; UIButton *beginPlay;}- (void)viewDidLoad { [super viewDidLoad]; [self initViews]; // Do any additional setup after loading the view, typically from a nib.}- (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated.}-(void)initViews{ leftDice=[[UILabel alloc]initWithFrame:CGRectMake(60, 100, 60, 100)]; [leftDice setBackgroundColor:[UIColor yellowColor]]; [leftDice setText:@"1"]; [leftDice setTextAlignment:(NSTextAlignmentCenter)]; [leftDice setTextColor:[UIColor blueColor]]; [self.view addSubview:leftDice]; rightDice=[[UILabel alloc]initWithFrame:CGRectMake(250, 100, 60, 100)]; [rightDice setBackgroundColor:[UIColor yellowColor]]; [rightDice setText:@"1"]; [rightDice setTextColor:[UIColor blueColor]]; [rightDice setTextAlignment:(NSTextAlignmentCenter)]; [self.view addSubview:rightDice]; beginPlay=[UIButton buttonWithType:UIButtonTypeRoundedRect]; [beginPlay setFrame:CGRectMake(150, 350, 75, 30)]; [beginPlay setTitle:@"开始掷骰子" forState:UIControlStateNormal]; [beginPlay setTitleColor:[UIColor blueColor] forState:UIControlStateNormal]; [beginPlay addTarget:self action:@selector(clickPlay:) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:beginPlay];}-(void)clickPlay:(UIButton *)sender{ NSInteger left=arc4random()%5+2; NSInteger right=arc4random()%5+2; self->leftDice.text=[NSString stringWithFormat:@"%ld",(long)left]; self->rightDice.text=[NSString stringWithFormat:@"%ld",(long)right]; if (left>=right) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"我赢了!!!" delegate:self cancelButtonTitle:@"哈哈再来一次" otherButtonTitles:@"不跟你玩儿了", nil]; [alert show]; } else { UIAlertView *alert1 = [[UIAlertView alloc] initWithTitle:@"" message:@"你赢了!!!" delegate:self cancelButtonTitle:@"哈哈再来一次" otherButtonTitles:@"不跟你玩儿了", nil]; [alert1 show]; } } @end
0 0
- 第一个iOS应用程序开发
- ios开发笔记 (1) 创建第一个ios 应用程序
- IOS 入门开发之构建第一个应用程序(一)
- IOS 入门开发之创建第一个应用程序
- 制作第一个 iOS 应用程序
- swift 第一个IOS应用程序
- swift 第一个IOS应用程序
- 【原创】第一个iOS应用程序
- 开发第一个Android应用程序
- 【iOS学习】第一个iOS应用程序
- IOS学习笔记(一)之安装开发环境与工具与第一个IOS应用程序
- Xamarin iOS开发实战第1章使用C#编写第一个iOS应用程序
- IOS第一个应用程序(HelloWorld)
- UI基础-01第一个iOS应用程序
- IOS 开发第一个HelloWorld
- 开发第一个iOS程序
- iOS开发-第一个App
- 用C#开发第一个WINDOWS应用程序
- float与double的精度值在编程中以及openGL超级宝典(第四版)及代码的错误之处#define M3D_INV_PI_DIV_180 (57.2957795130823229)
- web分页技术
- iOS开发网络请求
- Acronis backup & recovery
- 一步一步写简易版飞鸽传书(四)
- 第一个iOS应用程序开发
- 记一些前端框架
- Ubuntu14.04安装搜狗输入法和fontmanager修改字体
- ios深度解析之Swift(函数)
- java Exception 基础
- linux下用vim写基本的c程序
- HDOJ 题目4334 Trouble(hash)
- android eclipse的xml字体大小
- 基于Theano的深度学习(Deep Learning)框架Keras学习随笔-13-卷积层