1.旋转最好用Core Animation !
- (void)startAnimation
{
CABasicAnimation* rotationAnimation;
rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0 ];
rotationAnimation.duration = 1.f;
rotationAnimation.cumulative = YES;
rotationAnimation.repeatCount = MAXFLOAT;
[_inImageView.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];
}
2.怎么制作优雅的tableview loading效果:
可以在tableviewFooterView里面设置这个效果,因为显示出FooterView的时候肯定在刷新数据表之前
等刷新完Cell再将它替换掉,参考:仿开眼APP:https://github.com/iosfighterlb/OpenEyesDemo
HyTableViewFooterView:
@implementation HyTableViewFooterView
+ (instancetype) loadView
{
NSArray * ar = [[NSBundle mainBundle] loadNibNamed:@"HyTableViewFooterView" owner:self options:nil];
HyTableViewFooterView *footerView = [ar lastObject];
[footerView startAnimation];
footerView.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 68);
return [ar lastObject];
}
- (void)startAnimation
{
CABasicAnimation* rotationAnimation;
rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0 ];
rotationAnimation.duration = 1.f;
rotationAnimation.cumulative = YES;
rotationAnimation.repeatCount = MAXFLOAT;
[_inImageView.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];
}
@end
在ViewDidLoad中展示刷新界面:
_tableView.tableFooterView = [HyTableViewFooterView loadView];
viewForFooterInSection方法中刷新,将它替换或者移除(因为刷新完数据,这个方法会稍后才调用):
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
id obj = [_footerViews objectAtIndex:section];
if (section < _footerViews.count) {
if ([obj isKindOfClass:[UIView class]]) {
return obj;
}
}
HyTableViewCellFooterView *footerView = [HyTableViewCellFooterView loadView];
footerView.h = _tableView.rowHeight;
BaseClass *clas = [_dataSource objectAtIndex:section];
SectionList *list = [clas.sectionList lastObject];
footerView.data = [list.itemList firstObject];
[_footerViews insertObject:footerView atIndex:section];
return footerView;
}
3.自定义Cell的尺寸可以这样来设置:
@implementation VideoListTableViewCell
// 在这个方法中添加所有的子控件
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
UIImageView *image = [[UIImageView alloc] init];
[self.contentView addSubview:image];
self.ImageView = image;
UIImageView *shadeView = [[UIImageView alloc]init];
shadeView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.4];
self.shadeView = shadeView;
[image addSubview:self.shadeView];
UILabel *titleLabel = [[UILabel alloc] init];
titleLabel.textColor = [UIColor whiteColor];
titleLabel.font = [UIFont fontWithName:MyChinFont size:15.f];
titleLabel.textAlignment = NSTextAlignmentCenter;
[self.contentView addSubview:titleLabel];
self.titleLabel = titleLabel;
UILabel *messageLabel = [[UILabel alloc] init];
messageLabel.textColor = [UIColor whiteColor];
messageLabel.font = [UIFont systemFontOfSize:12.f];
messageLabel.textAlignment = NSTextAlignmentCenter;
[self.contentView addSubview:messageLabel];
self.messageLabel = messageLabel;
}
return self;
}
// 设置所有的子控件的frame
- (void)layoutSubviews
{
[super layoutSubviews];
self.ImageView.frame = self.bounds;
self.shadeView.frame = self.bounds;
/** 标题 */
self.titleLabel.frame = CGRectMake(5, self.bounds.size.height/2 - 20, self.bounds.size.width - 10, 30);
/** 信息 */
self.messageLabel.frame = CGRectMake(0, _titleLabel.bottom + 5, _titleLabel.width, 25);
}
@end
在layoutsubviews中设置,嘿嘿。
@property (nonatomic, strong) StoreViewController *storeViewController;
/
_storeViewController = (StoreViewController *)controller; //这里的controller是UIViewControoler类型
_storeViewController.serverID = serverId;