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 ...
随机推荐
- 黑苹果10.10.3手动开启SSD的TIRM提高硬盘效率
黑苹果10.10.3手动开启SSD的TIRM提高硬盘效率 文章前言 其实开启TIRM的方法有很多,比如用Clover注入的方式或者用其他的工具来方便完成,但是10.10.3刚刚出来有些工具还没有更新的 ...
- UVa-1368-DNA序列
这题的话,我们每次统计的话,是以列为外层循环,以行为内层循环,逐一按列进行比较. 统计完了之后,题目中要求说到要hamming值最小的,那我们就选用该列最多的字母就可以了,如果有数目相等的字母,那就按 ...
- 【树论 倍增】51nod1709 复杂度分析
倍增与位运算有很多共性:这题做法有一点像「线段树上二分」和「线段树套二分」的关系. 给出一棵n个点的树(以1号点为根),定义dep[i]为点i到根路径上点的个数.众所周知,树上最近公共祖先问题可以用倍 ...
- linux中添加一个用户到指定用户组的两种方式,修改一个用户到指定用户组的一种方式
添加一个用户到指定用户组: gpasswd –a 用户名 组名usermod –G 组名 用户名 //第一种:gpasswd –a 用户名 组名 [root@localhost ~]# id user ...
- 【css】背景图片填充
background: url(../img/icon_img/blue_gou.png) 0 0 no-repeat; background-size: cover; border-color: # ...
- 我的第一个ajax脚本
代码如下 //创建XMLHttpRequest对象 var xmlHttp=null; function creatXMLHttp(){ try{ xmlHttp = new XMLHttpReque ...
- centos 安装 yum apt
以下地址 http://download.csdn.NET/detail/mimi00x/8081263 执行安装命令 rpm -i rpmforge-release-0.5.3-1.el7.rf.x ...
- win7定时关机
菜单>附件>系统工具>任务计划程序>创建基本任务 alt+r>cmd>shutdown/? 查看相关参数 /l 注销 /s 关机 /r 重启 /g 重启,重启后,重 ...
- adb 命令大全
传送门 --> https://github.com/mzlogin/awesome-adb ADB,即 Android Debug Bridge,它是 Android 开发/测试人员不可替代的 ...
- WEB框架——WEB框架本质
武sir http://www.cnblogs.com/wupeiqi/articles/5237672.html