|
@@ -11,6 +11,9 @@
|
|
|
#define ROW_HEIGHT (80)
|
|
|
|
|
|
@interface AlbumSwitchView ()<UITableViewDelegate, UITableViewDataSource,UIGestureRecognizerDelegate>
|
|
|
+
|
|
|
+@property (weak, nonatomic) IBOutlet UIView *colorView;
|
|
|
+
|
|
|
@property (weak, nonatomic) IBOutlet UIView *backView;
|
|
|
|
|
|
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *topSpace;
|
|
@@ -44,13 +47,11 @@
|
|
|
gesture.delegate = self;
|
|
|
[self addGestureRecognizer:gesture];
|
|
|
self.backViewTop.constant = -300.0f;
|
|
|
+ self.colorView.backgroundColor = HexRGBAlpha(0x000000, 0.6f);
|
|
|
}
|
|
|
|
|
|
- (void)cancelSwitchAlbum {
|
|
|
- if (self.callback) {
|
|
|
- self.callback(ALBUMSWITCH_TYPE_CANCLE, 0);
|
|
|
- }
|
|
|
- [self removeFromSuperview];
|
|
|
+ [self hideActionSwitch:NO];
|
|
|
}
|
|
|
|
|
|
|
|
@@ -68,12 +69,31 @@
|
|
|
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
make.left.right.top.bottom.mas_equalTo(self.albumContainer);
|
|
|
}];
|
|
|
+ [self layoutIfNeeded]; // 约束立刻生效
|
|
|
+ // 动画
|
|
|
[self showAnimation];
|
|
|
}
|
|
|
|
|
|
- (void)showAnimation {
|
|
|
- [UIView animateWithDuration:0.5f animations:^{
|
|
|
- self.backViewTop.constant = 0.0f;
|
|
|
+ self.backViewTop.constant = 0;
|
|
|
+ [UIView animateWithDuration:0.3f animations:^{
|
|
|
+ [self layoutIfNeeded];
|
|
|
+ } completion:^(BOOL finished) {
|
|
|
+
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)hideAnimation {
|
|
|
+ self.colorView.backgroundColor = [UIColor clearColor];
|
|
|
+ NSInteger maxCountDisplay = self.sourceArray.count;
|
|
|
+ if (self.sourceArray.count > 5) {
|
|
|
+ maxCountDisplay = 5;
|
|
|
+ }
|
|
|
+ self.backViewTop.constant = -43 - maxCountDisplay * ROW_HEIGHT;
|
|
|
+ [UIView animateWithDuration:0.3f animations:^{
|
|
|
+ [self layoutIfNeeded];
|
|
|
+ } completion:^(BOOL finished) {
|
|
|
+ [self removeFromSuperview];
|
|
|
}];
|
|
|
}
|
|
|
|
|
@@ -123,15 +143,23 @@
|
|
|
}
|
|
|
self.lastChooseIndex = indexPath.row + 1000;
|
|
|
[self.tableView reloadData];
|
|
|
-// dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
- if (self.callback) {
|
|
|
+
|
|
|
+ [self hideActionSwitch:YES];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)hideActionSwitch:(BOOL)isModify {
|
|
|
+ if (self.callback) {
|
|
|
+ if (isModify == NO) {
|
|
|
+ self.callback(ALBUMSWITCH_TYPE_CANCLE, 0);
|
|
|
+ }
|
|
|
+ else {
|
|
|
self.callback(ALBUMSWITCH_TYPE_SWITCH, self.lastChooseIndex-1000);
|
|
|
}
|
|
|
- [self removeFromSuperview];
|
|
|
-// });
|
|
|
+ }
|
|
|
+
|
|
|
+ [self hideAnimation];
|
|
|
}
|
|
|
|
|
|
-
|
|
|
#pragma mark ----- gesture delegate
|
|
|
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
|
|
|
if ([touch.view isDescendantOfView:self.backView]) {
|