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 ...
随机推荐
- vue input 判断
//输入框 判断 //全局异常提示信息 //b 1:失去焦点验证错误提示 2:得到焦点关闭错误提示 //i 来区分是验证那个input框 check:function (t,b) { var that ...
- (41)zabbix监控api接口性能及可用性 天气预报api为例
现在各种应用都走api,例如淘宝,天气预报等手机.pad客户端都是走api的,那么平时也得对这些api做监控了.怎么做呢?zabbix的web监控是不二选择了.今天就以天气预报api作为一个例子. 天 ...
- Re:从零开始的Linux之路(杂谈)
决定认真从零开始写一个Linux的学习过程,像我这么偷懒的人能写文字记录已经很不容易了,希望不要半途而废吧(拖走) 用多了Linux其实发现,要是哪天Linux和Windows能结合下就好了,简单粗暴 ...
- RN踩坑
使用夜神 使用夜神作为模拟器,这个模拟器启动就会监听62001端口. 开发工具与模拟器的通信都是通过adb.夜神模拟器的安装目录/bin下有一个adb.exe,android sdk tools下也有 ...
- CSS3-弹性盒模型-FlexBox
Flex容器属性 display 定义一个Flex容器,根据其取的值来决定是内联还是块.Flex容器会为其内容建立新的伸缩格式化上下文. .container { display: flex; /* ...
- Python数据类型(简单入门)
数据类型(预了解) 1.数字类型 整型:int 即不带小数点的数,通常用来标识年龄,账号,身份证号,等级等整数. 浮点型:float 即带有小数点的数,通常用来标记身高,体重,科学计算等有小数点的数. ...
- linux 下常见命令
===============安装和登陆命令============================================================= Mount: 挂载命令.把存储介 ...
- WPF IP地址输入控件的实现
一.前言 WPF没有内置IP地址输入控件,因此我们需要通过自己定义实现. 我们先看一下IP地址输入控件有什么特性: 输满三个数字焦点会往右移 键盘←→可以空光标移动 任意位置可复制整段IP地址,且支持 ...
- Ubuntu新装系统要装软件
1. 在虚拟机中新安装系统的时候,通常因为时间过了很长,软件有更新之后,安装vim的时候会出错,因此,装完系统先要做的: cd /var/lib/dpkg/updates/ ls sudo apt-g ...
- vue.js+element-ui
git地址:https://github.com/jerry9022/LitAdmin vue.js+element-ui 做后台管理系统 太方便了