iOS-UI-Touch移动
来源:互联网 发布:淘宝怎么发布代销 编辑:程序博客网 时间:2024/06/07 20:03
View(继承于UIView,便于引用)
Controller#import "ViewController.h"#import "MoveView.h"@interface ViewController ()@property (nonatomic, retain) MoveView *mv;@end@implementation ViewController#pragma mark - 知识点1 重写Touch方法, 实现视图- (void)creatCustomView{ self.mv = [[MoveView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)]; self.mv.layer.cornerRadius = 50.; self.mv.layer.masksToBounds = YES; CGFloat e = arc4random()%(255 - 26 + 1) + 26; CGFloat eNum = e / 255; CGFloat f = arc4random()%(255 - 26 + 1) + 26; CGFloat fNum = f / 255; CGFloat g = arc4random()%(255 - 26 + 1) + 26; CGFloat gNum = g / 255; self.mv.backgroundColor = [UIColor colorWithRed:eNum green:fNum blue:gNum alpha:1]; [self.view addSubview:self.mv]; [self.mv release];}/* controll 重写touch move方法*/- (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{ NSLog(@"%@",touches); /* 取出集合中的对象 */ UITouch *touch = [touches anyObject]; //UITouch *touch = [[touches anyObject] class]; // NSLog(@"%@",[[touches anyObject] class]); /* 获取手指在view上的位置*/ CGPoint newPoint = [touch locationInView:self.view]; if (touch.view == self.mv) { /* 更改自定义view的center属性 */ self.mv.center = newPoint; } CGFloat e = arc4random()%(255 - 26 + 1) + 26; CGFloat eNum = e / 255; CGFloat f = arc4random()%(255 - 26 + 1) + 26; CGFloat fNum = f / 255; CGFloat g = arc4random()%(255 - 26 + 1) + 26; CGFloat gNum = g / 255; self.mv.backgroundColor = [UIColor colorWithRed:eNum green:fNum blue:gNum alpha:1];}- (void)dealloc{ [_mv release]; [super dealloc];}- (void)viewDidLoad { [super viewDidLoad]; [self creatCustomView]; // Do any additional setup after loading the view, typically from a nib.}- (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated.}@end
0 0
- iOS-UI-Touch移动
- iOS-UI-Touch事件
- iOS-Touch移动图解和控制器嵌套
- UI----Touch
- IOS UI学习 ScrollView中Touch事件作用子视图
- IOS UI学习 ScrollView中Touch事件作用子视图
- iOS 为移动动画中的View添加touch事件
- UI - Cocoa Touch框架
- 移动touch封装
- 使用touch移动元素
- 移动端touch事件
- 移动端滑屏 touch事件
- IOS 移动UI设计中的7种主要导航模式
- 移动开发iOS之如何在UI相框里实现动画
- [Phonegap+Sencha Touch] 移动开发27、禁用iOS系统的webapp电话号码自动识别
- [Phonegap+Sencha Touch] 移动开发23 Android和IOS的webview点击穿透的缓解办法
- [Phonegap+Sencha Touch] 移动开发27、禁用iOS系统的webapp电话号码自动识别
- IOS的处理touch事件处理(依照手指的移动移动一个圆,开发环境用的ios7,storyboard)
- 虚拟项目——计数器的verilog实现
- 3D游戏基础之五(渲染)
- auto_ptr、shared_ptr、weak_ptr、scoped_ptr用法小结
- Android基础之AutoCompleteTextView的使用
- 黑马程序员—基础—程序设计的学习方法
- iOS-UI-Touch移动
- 第四周 项目5 猴子选大王(1)
- C++11中的智能指针
- NSArray转NSData和NSData转NSArray
- 无为而治-科研之路有感而发
- 基于FP-Tree的关联规则FP-Growth推荐算法Java实现
- HTML5+CSS3学习(二)HTML5 语法规范
- 前言
- Android传感器框架分析