Nghe có vẻ thú vị, vì vậy tôi đã xem youtube. Video có vẻ như nó phát trong một hộp 16: 9 ở trên cùng, với danh sách "xem thêm" bên dưới. Khi người dùng thu nhỏ video, trình phát sẽ rơi xuống góc dưới bên phải cùng với chế độ xem "xem thêm". Đồng thời, chế độ xem "xem cũng" mờ dần trong suốt.
1) Thiết lập chế độ xem như thế và tạo ra các cửa hàng. Đây là những gì nó trông giống như trong IB. (Lưu ý rằng hai container là anh chị em ruột)
2) Cho xem video một swipe lên và trượt xuống cử chỉ recognizer:
@interface ViewController()
@property (weak, nonatomic) IBOutlet UIView *tallMpContainer;
@property (weak, nonatomic) IBOutlet UIView *mpContainer;
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
UISwipeGestureRecognizer *swipeDown = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeDown:)];
UISwipeGestureRecognizer *swipeUp = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeUp:)];
swipeUp.direction = UISwipeGestureRecognizerDirectionUp;
swipeDown.direction = UISwipeGestureRecognizerDirectionDown;
[self.mpContainer addGestureRecognizer:swipeUp];
[self.mpContainer addGestureRecognizer:swipeDown];
}
- (void)swipeDown:(UIGestureRecognizer *)gr {
[self minimizeMp:YES animated:YES];
}
- (void)swipeUp:(UIGestureRecognizer *)gr {
[self minimizeMp:NO animated:YES];
}
3) Và sau đó là một phương pháp để biết về trạng thái hiện tại và thay đổi trạng thái hiện tại.
- (BOOL)mpIsMinimized {
return self.tallMpContainer.frame.origin.y > 0;
}
- (void)minimizeMp:(BOOL)minimized animated:(BOOL)animated {
if ([self mpIsMinimized] == minimized) return;
CGRect tallContainerFrame, containerFrame;
CGFloat tallContainerAlpha;
if (minimized) {
CGFloat mpWidth = 160;
CGFloat mpHeight = 90; // 160:90 == 16:9
CGFloat x = 320-mpWidth;
CGFloat y = self.view.bounds.size.height - mpHeight;
tallContainerFrame = CGRectMake(x, y, 320, self.view.bounds.size.height);
containerFrame = CGRectMake(x, y, mpWidth, mpHeight);
tallContainerAlpha = 0.0;
} else {
tallContainerFrame = self.view.bounds;
containerFrame = CGRectMake(0, 0, 320, 180);
tallContainerAlpha = 1.0;
}
NSTimeInterval duration = (animated)? 0.5 : 0.0;
[UIView animateWithDuration:duration animations:^{
self.tallMpContainer.frame = tallContainerFrame;
self.mpContainer.frame = containerFrame;
self.tallMpContainer.alpha = tallContainerAlpha;
}];
}
tôi không thêm video vào dự án này, nhưng nó chỉ nên thả trong. Tận dụng tối mpContainer quan điểm mẹ của quan điểm của MPMoviePlayerController và nó sẽ trông khá mát mẻ.
Tôi thích hiệu ứng này quá, nhưng không có nhu cầu về một thư viện. Quan điểm của người chơi MP hoạt động như một cái nhìn bình thường. Đính kèm trình nhận dạng vuốt xuống và tạo hiệu ứng cho vị trí và khung hình của ứng dụng đó và ứng dụng của bạn sẽ tuyệt vời như google – danh
@danh, mọi khả năng bạn có thể đặt một số đoạn mã đơn giản để làm cho mọi thứ rõ ràng hơn. Cảm ơn nhiều. – shabbirh