屏幕适配的小技巧 pop动画 storyboard自定义cell的设置 tabbar隐藏大招
1.屏幕适配的小技巧
做屏幕适配的时候先模拟到你想要适配的最小尺寸,在这里加约束,这样换大屏的时候适配也就完成了,注意:autolayout+sizeClass 适配的时候一定要用any,any;
2. facebook的pop动画
方法:
使用cocoaPods导入pop 使用的时候引入 pop.h
pop 动画分为四大类
1. PopSpringAnimation 有弹性效果的动画类(推荐使用这种)
2. PopBasicAnimation 基本动画类
3. PopDecayAnimation 衰减动画类
1. PopSpringAnimation 有弹性效果的动画类(推荐使用这种)
2. PopBasicAnimation 基本动画类
3. PopDecayAnimation 衰减动画类
4. PopCustomAnimation 可以自定义动画的类
使用实例大概如下:
// 用PopSpringAnimation 让view实现弹性放大缩小的效果
POPSpringAnimation *springAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerSize];
CGRect rect = self.imageView.frame;
NSLog(@"%f",rect.size.width);
if (rect.size.width == 100) {
springAnimation.toValue = [NSValue valueWithCGSize:CGSizeMake(300, 300)];
} else {
springAnimation.toValue = [NSValue valueWithCGSize:CGSizeMake(100, 100)];
}
// 弹性值
springAnimation.springBounciness = 20.0;
// 弹性速度
springAnimation.springSpeed = 20.0;
[_imageView.layer pop_addAnimation:springAnimation forKey:@"changeSize"];
// 改变图片的position
POPSpringAnimation *springAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerPosition];
CGPoint point = _imageView.center;
if (point.y == 239) {
springAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(point.x, -238)];
} else {
springAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(point.x, 239)];
}
springAnimation.springBounciness = 20.0;
springAnimation.springSpeed = 20.0;
POPSpringAnimation *springAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerSize];
CGRect rect = self.imageView.frame;
NSLog(@"%f",rect.size.width);
if (rect.size.width == 100) {
springAnimation.toValue = [NSValue valueWithCGSize:CGSizeMake(300, 300)];
} else {
springAnimation.toValue = [NSValue valueWithCGSize:CGSizeMake(100, 100)];
}
// 弹性值
springAnimation.springBounciness = 20.0;
// 弹性速度
springAnimation.springSpeed = 20.0;
[_imageView.layer pop_addAnimation:springAnimation forKey:@"changeSize"];
// 改变图片的position
POPSpringAnimation *springAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerPosition];
CGPoint point = _imageView.center;
if (point.y == 239) {
springAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(point.x, -238)];
} else {
springAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(point.x, 239)];
}
springAnimation.springBounciness = 20.0;
springAnimation.springSpeed = 20.0;
[_imageView pop_addAnimation:springAnimation forKey:@"changePositon"];
3. self.userTableView registerNib:[UINib nibWithNibName:@"BuyTableViewCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"Cell"];
这个方法的作用是注册用xib拖出来的自定义cell,只有这样storyboard才能识别出自定义的cell并且显示出来;第一个参数是文件名,第二个参数是cell得identifier
4.myVC.hidesBottomBarWhenPushed = YES; // push界面的时候设置这个属性,会将tabbar隐藏,并且返回的时候tabor会自动显示。

浙公网安备 33010602011771号