今天带来的是仿百度外卖,饿了么-点餐效果既物品加入购物车时的动画效果,这里用的Masonry布局,下滑的效果主要是通过UIBezierPath CAKeyframeAnimation CABasicAnimation以及CAAnimationGroup实现的
因为写的比较匆忙 注释不是很多,而且界面用的都是色块,只能将就着看了.....
下面蓝色的 button 也是会动的,由于没做 gif 图,就只能用截图将就着看了,代码如下
首先是 自定义cell
//
// MyTableViewCell.h
// 仿百度外卖-点餐效果
//
// Created by Amydom on 16/12/5.
// Copyright © 2016年 Amydom. All rights reserved.
//
#import <UIKit/UIKit.h>
//block 用于响应 cell 上 button 点击方法
typedef void (^btnPulsBlock)(NSInteger count , BOOL animated);
@interface MyTableViewCell : UITableViewCell
@property (nonatomic, strong) UIImageView *foodImage; // cyan
@property (nonatomic, strong) UILabel *nameLabel; // orange
@property (nonatomic, strong) UILabel *priceLabel; // gray
@property (nonatomic, strong) UIButton *btnMinus; // black
@property (nonatomic, strong) UIButton *btnPlus; // black
@property (nonatomic, strong) UILabel *orderCount; // red
@property (nonatomic, copy) btnPulsBlock block; // block
@property (nonatomic, strong) UIImageView *animateView; // 购物车图标
@property (nonatomic, assign) NSInteger numCount; // 计数器
@end
// // MyTableViewCell.m // 仿百度外卖-点餐效果 // // Created by Amydom on 16/12/5. // Copyright © 2016年 Amydom. All rights reserved. // #import "MyTableViewCell.h" #import "Masonry.h" @implementation MyTableViewCell - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { [self createSubviews]; } return self; } - (void)createSubviews { //因为采用懒加载,所以