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. Vue构建项目

    构建Vue项目 按照官网教程安装 //先安装脚手架 cnpm i -g vue-cli //查看项目目标列表: webpack browserify pwa 等项目模板 vue list //使用we ...

  2. HDU-2544-最短路(floyd)

    板子题,实验一下floyd. #include <cstdio> #include <algorithm> #include <cstring> using nam ...

  3. 【二分】bestcoder p1m2

    模型的转化和二分check的细节挺不错的 Problem Description 度度熊很喜欢数组!! 我们称一个整数数组为稳定的,若且唯若其同时符合以下两个条件: 数组里面的元素都是非负整数. 数组 ...

  4. 使用Fiddler抓取Android模拟器中的Android_APP请求

    对Fiddler的设置:在https://www.telerik.com/download/fiddler网站上下载Fiddler,输入内容后点击下面按钮进行下载: 下载成功后,打开Fiddler进行 ...

  5. nginx 部署ssl证书之后访问用火狐出现SSL_ERROR_RX_RECORD_TOO_LONG此错误,用Google出现ERR_SSL_PROTOCOL_ERROR错误

    server { listen ; server_name xxx.com; ssl_certificate ssl/xxx.pem; ssl_certificate_key ssl/xxx.key; ...

  6. 【DB_MySQL】查询语句中各子句的执行顺序

    1. FROM 指明查询来源 2. WHERE筛选元组 3. GROUP BY进行分组 4. HAVING 筛选分组 5. SELECT 投影出指定的字段列 6. ORDER BY 对结果集排序 7. ...

  7. Elementary OS上eclipse卡死问题

    解决: 1.可以用  sudo ./eclipse -vm /home/username/jdk_path/bin/java 启动但是启动后仍有显示问题. 2. 修改 eclipse.ini 在 -- ...

  8. python上的数据库sqlite3——插入多行数据

    学校课程上的一个知识点,一个简单的课后习题:一劳永逸实现多行数据的插入(应该是这个意思,老师也没讲清楚).直接上代码了没啥好讲的,我感觉这个思路好捞. import sqlite3 con = sql ...

  9. (转)Objective-C语法之动态类型(isKindOfClass, isMemberOfClass,id)等

    本文转自http://blog.csdn.net/totogo2010/article/details/7714960 对象在运行时获取其类型的能力称为内省.内省可以有多种方法实现. 判断对象类型 - ...

  10. (原)剑指offer之旋转数组

    题目描述 把一个数组最开始的若干个元素搬到数组的末尾,我们称之为数组的旋转. 输入一个递增排序的数组的一个旋转,输出旋转数组的最小元素. 例如数组{3,4,5,1,2}为{1,2,3,4,5}的一个旋 ...