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 ...
随机推荐
- 【NOIP2017提高A组冲刺11.8】购物
这个范围对DP不友好,和CF的一道C题非常像,贪心+后悔. 先使用k个优惠券购买k个q最小的(钱不购买则退出),同时把这k个p[i]-q[i]放入小根堆,然后将剩下的n-k个按p升序排序,记小根堆堆顶 ...
- 【git】自动换行转换autocrlf
#####windows git config --global core.autocrlf true #####linux git config --global core.autocrlf inp ...
- 【编码】【转发】enca 转换编码
enca用法如下: enca -L zh_CN file 检查文件的编码 enca -L zh_CN -x UTF-8 file 将文件编码转换为"UTF-8"编码 enca -L ...
- (转) [C++]我再也不想在任何头文件中看到using namespace xxx这种句子了(译)
原文的传送:I don’t want to see another “using namespace xxx;” in a header file ever again 转自 http://blog ...
- 【HIHOCODER 1529】 不上升序列
描述 给定一个长度为 n 的非负整数序列 a[1..n]. 你每次可以花费 1 的代价给某个 a[i] 加1或者减1. 求最少需要多少代价能将这个序列变成一个不上升序列. 输入 第一行一个正整数 n. ...
- 关于Linux下安装Oracle
参考文档:http://www.cnblogs.com/gaojun/archive/2012/11/22/2783257.html 中文字符集设置: http://blog.csdn.net/ ...
- grunt与seajs结合应用
9.seajs构建的问题 01.png和02.jpg 10.seajs与grunt如何结合开发.两个插件:grunt-cmd-transport grunt-cmd-contact ,去grunt官网 ...
- luogu1963 [NOI2009]变换序列
#include <iostream> #include <cstring> #include <cstdio> using namespace std; int ...
- How To Configure VMware fencing using fence
本文主要简单介绍一下如何在RHEL 7 Pacemaker中配置一个fence_vmware_soap类型的STONITH设备(仅供测试学习). STONITH是Shoot-The-Other-Nod ...
- NOS跨分区灾备设计与实现
本文来自网易云社区 作者:王健 摘要 NOS(网易对象存储)在实现多机房(杭州机房,北京机房等)部署后,允许一个用户在建桶时选择桶所属机房.在此基础上,我们实现了跨机房的数据复制,进一步实现了跨机房的 ...