uicollectionview 使用uibutton或者uiimageview实现旋转出现scale的问题
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的问题的更多相关文章
- iOS开发——UI基础-UIButton、UIImageView、UILabel的选择
1.UILabel - UILabel的常见属性 @property(nonatomic,copy) NSString *text; 显示的文字 @property(nonatomic,retain) ...
- UIButton、UIImageView、UILabel的选择
UIButton特点既能显示文字,又能显示图片(能显示2张图片,背景图片.内容图片)长按高亮的时候可以切换图片\文字直接通过addTarget...方法监听点击 UIImageView能显示图片,不能 ...
- ##DAY2 UILabel、UITextField、UIButton、UIImageView、UISlider
##DAY2 UILabel.UITextField.UIButton.UIImageView.UISlider #pragma mark ———————UILabel——————————— UILa ...
- UITextFiled,UIButton,UIImageView交互相互之间的事件拦截
UIButton右上方添加一个笑button如: UIButton *button =[UIButton buttonWithType:UIButtonTypeCustom]; button.f ...
- IOS中UIButton和UIImageView的区别
1.使用场合 UIImageView:如果仅仅是为了显示图片,不需要监听图片的点击事件 UIButton:既要显示图片,又要监听图片等点击事件 2.相同点 都能显示图片 3.不同点 UIButton能 ...
- UIButton和UIImageView的区别
1.显示图片 1> UIImageView只能一种图片(图片默认会填充整个UIImageView) image\setImage: 2> UIButton能显示2种图片 * 背景 (背景 ...
- UIButton和UIimageView
1.按钮控件使用的类是UIButton 点击按钮会触发某个事件 2.按钮控件的初始化 UIButton *button = [UIButton buttonWithType:UIButtonTypeC ...
- css3 新特性(2D translate 移动,rotate 旋转 , scale 缩放)
1.transform(转换)可以实现元素的位移,旋转,缩放等效果(可以简单理解为变形) 移动:translate 旋转:rotate 缩放:scale 2. ...
- iOS基础 - UIButton - UIImageView
封装思想:将相同的重复东西保存到方法里,不同的东西用参数代替.不相同的东西交给方法调用者,相同东西自己搞定. 一.UIButton和UIImageView的区别 1.显示图片 1> UIImag ...
随机推荐
- MYSQL数据库SQL语句集锦
*特别说明:FILED代表数据表字段,CONDITIONS代表where之后的条件,TABLENAME代表数据表名 []中括号内的内容代表 可有可无. 创建数据库 create database ...
- Spring Boot + Mybatis + Druid 动态切换多数据源
在大型应用程序中,配置主从数据库并使用读写分离是常见的设计模式. 在Spring应用程序中,要实现读写分离,最好不要对现有代码进行改动,而是在底层透明地支持. 这样,就需要我们再一个项目中,配置两个, ...
- Ubuntu sudo 出现 is not in the sudoers file解决方案
前言: 自己想额外创建一个Linux账户,但是发现新创建的用户(lgq)并不能使用sudo指令. 但是在安装系统时创建的用户(abc)是可以正常使用的. 原因是新创建的用户并没有被赋予使用sudo指令 ...
- python计算机基础(一)
什么是编程语言? 跟计算机交流的语言 什么是编程? 编程就是写代码,让计算机能够听懂的语言 为什么要编程? 让计算机为我们做事,取代人 计算机5大组成分别有什么作用? CPU:控制,判断,配作用,内存 ...
- web开发框架之DRF
RESTful架构解释: # Representational State Transfer 表现层状态转化 到底什么是RESTFul架构: 如果一个架构符合REST原则,就称它为RESTful架构. ...
- I2C驱动框架(三)
参考:I2C子系统之platform_device初始化——smdk2440_machine_init() I2C驱动框架还应用了另一种总线-设备-驱动模型,平台设备总线platform_bus_ty ...
- PAT Basic 1029
1029 旧键盘 旧键盘上坏了几个键,于是在敲一段文字的时候,对应的字符就不会出现.现在给出应该输入的一段文字.以及实际被输入的文字,请你列出肯定坏掉的那些键. 输入格式: 输入在2行中分别给出应该输 ...
- 00051_static关键字
1.static概念 当在定义类的时候,类中都会有相应的属性和方法.而属性和方法都是通过创建本类对象调用的.当在调用对象的某个方法时,这个方法没有访问到对象的特有数据时,方法创建这个对象有些多余.可是 ...
- Python 多级目录选择+一键正反排序
效果如图所示,可以根据条件来选择对象 cat pc.py #!/usr/bin/pythonfrom flask import Flask,render_template,request,redire ...
- appium+python自动化-xpath定位
基本属性定位 以淘宝app为例,定位左上角扫一扫按钮 1.可以通过text文本定位到 //*[@text='text文本属性'] # 定位text driver.find_element_by_xpa ...