UI - UIImageView 和页面跳转
2015-08-25 21:06
513 查看
这节课做了UIImageView的静态图和动态图的添加,并且添加手势,使页面跳转,下面是代码部分
#RootViewController #import "RootViewController.h" #import "SecondViewController.h" @interface RootViewController () @end @implementation RootViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. // 如果图片的名字是以png结尾 可以只写图片名 否则图片名和格式都要写出来 // UIImage *image = [UIImage imageNamed:@"2"]; UIImage *image = [UIImage imageWithContentsOfFile:@"/Users/lanou/Desktop/壁纸/97054020.jpg"]; UIImageView *imageView = [[UIImageView alloc]initWithImage:(image)]; imageView.frame = CGRectMake(10, 30, 350, 400); imageView.userInteractionEnabled = YES; [self.view addSubview:imageView]; [imageView release]; // 创建一个轻拍手势 UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(doTap:)]; [imageView addGestureRecognizer:tap]; [tap release]; /* NSMutableArray *arr = [NSMutableArray arrayWithCapacity:0]; UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(50, 50, 100, 100)]; for (int i = 1; i <= 2; i++) { UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"1-%d(被拖移).tiff", i]]; [arr addObject:image]; } imageView.animationImages = arr; [imageView setAnimationDuration:0.5]; [imageView setAnimationRepeatCount:4]; [imageView startAnimating]; [self.view addSubview:imageView]; [imageView release]; */ } - (void)doTap:(UITapGestureRecognizer *)tap { // 通过tap.view可以获得当前手势放置在哪一个view上 // NSLog(@"被点击了 (╯‵□′)╯︵┻━┻ FUCK NO%@", tap.view); //进入第二个界面 //1>创建第二个界面 SecondViewController *secondVC = [[SecondViewController alloc]init]; //2>进入 [self presentViewController:secondVC animated:YES completion:^{ }]; [secondVC release]; } #SecondViewController.m #import "SecondViewController.h" @interface SecondViewController () @end @implementation SecondViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. UIButton *returnButton = [UIButton buttonWithType:(UIButtonTypeSystem)]; returnButton.frame = CGRectMake(50, 350, 80, 30); returnButton.backgroundColor = [UIColor yellowColor]; [returnButton setTitle:@"返回" forState:(UIControlStateNormal)]; [returnButton addTarget:self action:@selector(didClickRetureButtonAction:) forControlEvents:(UIControlEventTouchDragInside)]; [self.view addSubview:returnButton]; } #pragma mark - back - (void)didClickRetureButtonAction:(UIButton *)button { [self dismissViewControllerAnimated:YES completion:^{ }]; }
相关文章推荐
- GUI - Web前端开发框架
- 评价ui设计作品好坏的八个标准(界面/交互设计研究)
- 为Yahoo! UI Extensions Grid增加内置的可编辑器
- Cocos2d-x UI开发之文本类使用实例
- php开发中的页面跳转方法总结
- JS option location 页面跳转实现代码
- 在IE 浏览器中使用 jquery的fadeIn() 效果 英文字符字体加粗
- UI Events 用户界面事件
- 基于jQuery UI CSS Framework开发Widget的经验
- jquery ui 1.7 ui.tabs 动态添加与关闭(按钮关闭+双击关闭)
- jQuery UI的Dialog无法提交问题的解决方法
- 关于jQuery UI 使用心得及技巧
- jQuery ui 1.7更新小结
- jquery mobile页面跳转后样式丢失js失效的解决方法
- 从零开始学习jQuery (十) jQueryUI常用功能实战
- 五种 JSP页面跳转方法详解
- Ruby rails 页面跳转(render和redirect_to)
- jquery ui对话框实例代码
- javascript 页面跳转方法集合
- jQuery UI AutoComplete 自动完成使用小记