uicollectionview下单独使用uibutton然后setimage或者直接使用uiimageview然后一定角度旋转后发现size会变动

解决方案:添加uibutton到uicollectionvview然后添加uiimageview到uibutton上而后旋转没有问题

但是点击时候即便设置的uiimageview的相关可点击属性依然无法实现button的点击,解决途径:tapgesture判断

代码如下:

self.subThemeGobackBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    self.subThemeGobackBtn.frame = CGRectMake(self.collectionView.bounds.size.width / 2 + 60.0f, positionY, 0.0f, 0.0f);
    [self.subThemeGobackBtn setBackgroundColor:[UIColor clearColor]];
    //    [self.subThemeGobackBtn addTarget:self action:@selector(gobackToPerviousScreen:) forControlEvents:UIControlEventTouchUpInside];
    [self.collectionView addSubview:self.subThemeGobackBtn];
    
    self.buttonImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"gobackicon.png"]];
    self.buttonImageView.frame = CGRectMake(0.0f, 0.0f, 100.0f, 20.0f);
    self.buttonImageView.alpha = 0.0f;
    self.buttonImageView.tag = 0;
    self.buttonImageView.backgroundColor = [UIColor blueColor];
    self.buttonImageView.userInteractionEnabled = YES;
    
    [self.subThemeGobackBtn addSubview:self.buttonImageView];
    
    [UIView animateWithDuration:0.3f
                          delay:0.0f
                        options:UIViewAnimationOptionBeginFromCurrentState
                     animations:^ {
                         
                         if (angle != 0.0f){
                             self.subThemeGobackBtn.frame = CGRectMake(positionX, positionY, 0.0f, 0.0f);
                             
                             
                         }else{
                             self.subThemeGobackBtn.frame = CGRectMake(positionX, positionY, 120.0f, 23.0f);
                             self.buttonImageView.alpha = 1.0f;
                             
                         }
                     }completion:^(BOOL finished){
                         
                         if (angle != 0.0f) {
                             
                             [UIView animateWithDuration:0.0f
                                                   delay:0.0f
                                                 options:UIViewAnimationOptionBeginFromCurrentState
                                              animations:^ {
                                                  
                                                  
                                                  self.subThemeGobackBtn.transform =                                                   CGAffineTransformMakeRotation(angle + M_PI);
                                                  
                                                  // Commit the changes
                                                  [UIView commitAnimations];
                                                  
                                              }completion:^(BOOL finished){
                                                  
                                                  CGFloat positiony = self.centercell.frame.origin.y;
                                                  CGFloat positionx = self.centercell.frame.origin.x;
                                                  
                                                  if (self.centercell.frame.origin.y > self.collectionView.bounds.size.height / 2) {
                                                      
                                                      positiony = self.collectionView.bounds.size.height / 2 - (self.centercell.frame.origin.y - self.collectionView.bounds.size.height / 2 ) - 65.0f ;
                                                      
                                                  }else{
                                                      positiony = self.collectionView.bounds.size.height / 2 + (self.collectionView.bounds.size.height / 2 -self.centercell.frame.origin.y) - 65.0f;
                                                      
                                                  }
                                                  if (self.centercell.frame.origin.x > self.collectionView.bounds.size.width / 2) {
                                                      
                                                      positionx = self.collectionView.bounds.size.width -  130.0f;
                                                      
                                                  }else{
                                                      
                                                      positionx = 20.0f;
                                                      if ((4 < -angle ) && (-angle < 5))
                                                      {
                                                          
                                                          positionx = self.collectionView.bounds.size.width / 2;
                                                          positiony = self.collectionView.bounds.size.height / 2 - (self.centercell.frame.origin.y - self.collectionView.bounds.size.height / 2 ) - 70.0f ;
                                                      }
                                                      
                                                  }
                                                  [UIView animateWithDuration:0.0f
                                                                        delay:0.0f
                                                                      options:UIViewAnimationOptionBeginFromCurrentState
                                                                   animations:^ {
                                                                       
                                                                       self.buttonImageView.alpha = 1.0f;
                                                                       
                                                                       self.subThemeGobackBtn.frame = CGRectMake(positionx, positiony, 0.0f, 0.0f);
                                                                       
                                                                       
                                                                   }completion:^(BOOL finished){
                                                                       
                                                                       [UIView beginAnimations:nil context:NULL];
                                                                       [UIView setAnimationDuration:0.25f];
                                                                       self.subThemeGobackBtn.frame = CGRectMake(positionx, positiony, 120.0f, 23.0f);
                                                                       
                                                                       [UIView commitAnimations];
                                                                       
                                                                   }];
                                                  
                                                  
                                              }];
                             
                         }
                         
                     }];
    
}

uicollectionview 使用uibutton或者uiimageview实现旋转出现scale的问题的更多相关文章

  1. iOS开发——UI基础-UIButton、UIImageView、UILabel的选择

    1.UILabel - UILabel的常见属性 @property(nonatomic,copy) NSString *text; 显示的文字 @property(nonatomic,retain) ...

  2. UIButton、UIImageView、UILabel的选择

    UIButton特点既能显示文字,又能显示图片(能显示2张图片,背景图片.内容图片)长按高亮的时候可以切换图片\文字直接通过addTarget...方法监听点击 UIImageView能显示图片,不能 ...

  3. ##DAY2 UILabel、UITextField、UIButton、UIImageView、UISlider

    ##DAY2 UILabel.UITextField.UIButton.UIImageView.UISlider #pragma mark ———————UILabel——————————— UILa ...

  4. UITextFiled,UIButton,UIImageView交互相互之间的事件拦截

    UIButton右上方添加一个笑button如: UIButton *button =[UIButton buttonWithType:UIButtonTypeCustom];    button.f ...

  5. IOS中UIButton和UIImageView的区别

    1.使用场合 UIImageView:如果仅仅是为了显示图片,不需要监听图片的点击事件 UIButton:既要显示图片,又要监听图片等点击事件 2.相同点 都能显示图片 3.不同点 UIButton能 ...

  6. UIButton和UIImageView的区别

    1.显示图片 1> UIImageView只能一种图片(图片默认会填充整个UIImageView)  image\setImage: 2> UIButton能显示2种图片 * 背景 (背景 ...

  7. UIButton和UIimageView

    1.按钮控件使用的类是UIButton 点击按钮会触发某个事件 2.按钮控件的初始化 UIButton *button = [UIButton buttonWithType:UIButtonTypeC ...

  8. css3 新特性(2D translate 移动,rotate 旋转 , scale 缩放)

    1.transform(转换)可以实现元素的位移,旋转,缩放等效果(可以简单理解为变形) 移动:translate            旋转:rotate          缩放:scale 2. ...

  9. iOS基础 - UIButton - UIImageView

    封装思想:将相同的重复东西保存到方法里,不同的东西用参数代替.不相同的东西交给方法调用者,相同东西自己搞定. 一.UIButton和UIImageView的区别 1.显示图片 1> UIImag ...

随机推荐

  1. [LUOGU] P1551 亲戚

    题目背景 若某个家族人员过于庞大,要判断两个是否是亲戚,确实还很不容易,现在给出某个亲戚关系图,求任意给出的两个人是否具有亲戚关系. 题目描述 规定:x和y是亲戚,y和z是亲戚,那么x和z也是亲戚.如 ...

  2. Mycat主从分离

    1. mycat原理 主从的读写是不同的,主能写能读,再从上写是无法同步到主的,因此需要中间件将主从的读写进行分离,使得主从各司其职,相当于负载均衡的作用.中间件可以是proxy或者mycat.客户端 ...

  3. Git学习——删除文件

    怎么删除版本库中的文件呢? 首先,删除工作区中的文件:rm <file>,然后你有两个选择.其一是,真正删除版库中的文件: git rm <file> git commit - ...

  4. django第六天(模板相关,过滤器和标记)

    django第6天 DTL简介 django template language django模板语言 语法: filter{{}} tag{% %} 简单变量的使用 视图函数可以通过两种方式将变量船 ...

  5. Exchange 邮件服务器内存硬盘估算

  6. python模拟浏览器webdriver登陆网站后抓取页面并输出

    关键在于以下两行代码 特别是find_element_by_xpath写法 很多写成 findElementsByXpath不知道是写错了 还是高级版本是这么写的... #webElement = s ...

  7. 大数据学习——kafka+storm+hdfs整合

    1 需求 kafka,storm,hdfs整合是流式数据常用的一套框架组合,现在 根据需求使用代码实现该需求 需求:应用所学技术实现,kafka接收随机句子,对接到storm中:使用storm集群统计 ...

  8. ER模型图工具:PowerDesigner

    导读:开始是想一个阶段一个阶段的写文档,再写了可行性分析报告之后,发现这种方法整体性不强,写出来的文档也总是有考虑不周的地方.后来,就看完了全部的软工视频再写.现在该写项目开发总结报告了.在写文档的过 ...

  9. C++之字符串表达式求值

    关于字符串表达式求值,应该是程序猿们机试或者面试时候常见问题之一,昨天参加国内某IT的机试,压轴便为此题,今天抽空对其进行了研究. 算术表达式中最常见的表示法形式有 中缀.前缀和 后缀表示法.中缀表示 ...

  10. 【组合数+Lucas定理模板】HDU 3037 Saving

    acm.hdu.edu.cn/showproblem.php?pid=3037 [题意] m个松果,n棵树 求把最多m个松果分配到最多n棵树的方案数 方案数有可能很大,模素数p 1 <= n, ...