直播当中的装饰品
2016-07-28 14:03
357 查看
神灯产品用户体验群:573431381
在直播界面,需要给主播一些小的装饰品如发卡,面具,帽子等。
![](https://img-blog.csdn.net/20160728135750247)
通常会有拖拉 、旋转、缩放等,下面简单介绍,这几中手势。
直接看代码
“`
//装饰品
- (void)adornButtonClick
{
UIImageView *panView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 100, 50, 50)];
[self.view addSubview:panView];
panView.userInteractionEnabled = YES;
[panView setMultipleTouchEnabled:YES];
panView.backgroundColor = [UIColor clearColor];
panView.image = [ UIImage imageNamed:@”面具.jpg”];
// 拖动手势
UIPanGestureRecognizer * panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(doHandlePanAction:)];
[panView addGestureRecognizer:panGestureRecognizer];
// 旋转手势
UIRotationGestureRecognizer *rotationGestureRecognizer = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotateView:)];
[panView addGestureRecognizer:rotationGestureRecognizer];
}
//拖动手势
- (void) doHandlePanAction:(UIPanGestureRecognizer *)paramSender{
}
// 处理旋转手势
- (void) rotateView:(UIRotationGestureRecognizer *)rotationGestureRecognizer
{
UIView *view = rotationGestureRecognizer.view;
if (rotationGestureRecognizer.state == UIGestureRecognizerStateBegan || rotationGestureRecognizer.state == UIGestureRecognizerStateChanged) {
view.transform = CGAffineTransformRotate(view.transform, rotationGestureRecognizer.rotation);
[rotationGestureRecognizer setRotation:0];
}
}
// 处理缩放手势
- (void) pinchView:(UIPinchGestureRecognizer *)pinchGestureRecognizer
{
UIView *view = pinchGestureRecognizer.view;
if (pinchGestureRecognizer.state == UIGestureRecognizerStateBegan || pinchGestureRecognizer.state == UIGestureRecognizerStateChanged) {
view.transform = CGAffineTransformScale(view.transform, pinchGestureRecognizer.scale, pinchGestureRecognizer.scale);
pinchGestureRecognizer.scale = 1;
}
}
“`记得要添加
panView.userInteractionEnabled = YES;
[panView setMultipleTouchEnabled:YES];
这样效果能显示出来
在直播界面,需要给主播一些小的装饰品如发卡,面具,帽子等。
通常会有拖拉 、旋转、缩放等,下面简单介绍,这几中手势。
直接看代码
“`
//装饰品
- (void)adornButtonClick
{
UIImageView *panView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 100, 50, 50)];
[self.view addSubview:panView];
panView.userInteractionEnabled = YES;
[panView setMultipleTouchEnabled:YES];
panView.backgroundColor = [UIColor clearColor];
panView.image = [ UIImage imageNamed:@”面具.jpg”];
// 拖动手势
UIPanGestureRecognizer * panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(doHandlePanAction:)];
[panView addGestureRecognizer:panGestureRecognizer];
// 旋转手势
UIRotationGestureRecognizer *rotationGestureRecognizer = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotateView:)];
[panView addGestureRecognizer:rotationGestureRecognizer];
// 缩放手势 UIPinchGestureRecognizer *pinchGestureRecognizer = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(pinchView:)]; [panView addGestureRecognizer:pinchGestureRecognizer];
}
//拖动手势
- (void) doHandlePanAction:(UIPanGestureRecognizer *)paramSender{
CGPoint point = [paramSender translationInView:self.view]; NSLog(@"X:%f;Y:%f",point.x,point.y); paramSender.view.center = CGPointMake(paramSender.view.center.x + point.x, paramSender.view.center.y + point.y); [paramSender setTranslation:CGPointMake(0, 0) inView:self.view];
}
// 处理旋转手势
- (void) rotateView:(UIRotationGestureRecognizer *)rotationGestureRecognizer
{
UIView *view = rotationGestureRecognizer.view;
if (rotationGestureRecognizer.state == UIGestureRecognizerStateBegan || rotationGestureRecognizer.state == UIGestureRecognizerStateChanged) {
view.transform = CGAffineTransformRotate(view.transform, rotationGestureRecognizer.rotation);
[rotationGestureRecognizer setRotation:0];
}
}
// 处理缩放手势
- (void) pinchView:(UIPinchGestureRecognizer *)pinchGestureRecognizer
{
UIView *view = pinchGestureRecognizer.view;
if (pinchGestureRecognizer.state == UIGestureRecognizerStateBegan || pinchGestureRecognizer.state == UIGestureRecognizerStateChanged) {
view.transform = CGAffineTransformScale(view.transform, pinchGestureRecognizer.scale, pinchGestureRecognizer.scale);
pinchGestureRecognizer.scale = 1;
}
}
“`记得要添加
panView.userInteractionEnabled = YES;
[panView setMultipleTouchEnabled:YES];
这样效果能显示出来
相关文章推荐
- 优酷的菜单
- Spring依赖注入详解
- Trie树的DAT实现
- DLL的结构
- MySQL查询结果保存到本地
- (原+译)win7远程连接ubuntu16.04
- c#——Winform TreeView 赋值(id,name,pid)类型数据
- 使用Egret开发的HTML5项目,使用本地电脑作为服务器进行移动端调试流程
- Maven项目中使用本地JAR包
- PYTHON黑帽编程1.5 使用WIRESHARK练习网络协议分析
- ROS by example -第十二章 DYNAMIXEL 伺服系统和 ROS
- 图片防盗链
- 文章标题
- MFC通过txt查找文件并进行复制-备忘
- 综合日语第一册动词复习
- PAT1084
- NKOI 3728 彩虹小马与魔法数列
- 今天开始重新更新(ps:广接各种php相关的外包项目,有意者请留言或者私聊)
- A - Red and Black POJ 1979
- 使用T-Code:ST05 追踪