测试已测试 | ✗ |
语言语言 | SwiftSwift |
许可协议 | MIT |
发布上次发布 | 2016年6月 |
SPM支持 SPM | ✗ |
由 Sarp Solakoglu 维护。
适用于类似 Instagram 应用中视频缩略图(封面)选择的选型工具。使用 Swift 2.2 编写。
您可以在 Storyboard 中添加一个 UIView,并设置 Class 和 Module 属性为 VideoThumbnailSelectionView。
之后,使用相关的 IBOutlet 建立连接。
Swift
@IBOUtlet weak var videoThumbnailSelectionView: VideoThumbnailSelectionView!
Obj-c
@property (weak, nonatomic) IBOutlet VideoThumbnailSelectionView *videoThumbnailSelectionView;
您也可以从代码中初始化视图。
Swift
import VideoThumbnailSelectionView
.
.
var videoThumbnailSelectionView: VideoThumbnailSelectionView!
.
.
.
videoThumbnailSelectionView = VideoThumbnailSelectionView(frame:CGRectMake(20.0, 20.0, 325.0, 60.0))
view.addSubview(selectionView)
Obj-c
@import VideoThumbnailSelectionView;
.
.
@property (strong, nonatomic) VideoThumbnailSelectionView * videoThumbnailSelectionView;
.
.
.
_videoThumbnailSelectionView = [[VideoThumbnailSelectionView alloc] initWithFrame:CGRectMake(20.0, 20.0, 325.0, 60.0)];
[self.view addSubview:selectionView];
Swift
//Alpha of the black tint on the thumbnails behind the thumb
videoThumbnailSelectionView.shadeTintAlpha = 0.5
//scale animation when thumb is dragged (1.0 for no animation).
videoThumbnailSelectionView.zoomAnimationScale = 1.5
//corner color
videoThumbnailSelectionView.cornerColor = .whiteColor()
//corner radius
videoThumbnailSelectionView.cornerRadius = 8.0
//corner thickness
videoThumbnailSelectionView.cornerInsets = UIEdgeInsetsMake(6.0, 6.0, 6.0, 6.0)
//called when selection changes
videoThumbnailSelectionView.onUpdatedImage = { image in
//do stuff with the image
};
Obj-c
//Alpha of the black tint on the thumbnails behind the thumb
_videoThumbnailSelectionView.shadeTintAlpha = 0.5;
//scale animation when thumb is dragged (1.0 for no animation).
_videoThumbnailSelectionView.zoomAnimationScale = 1.5;
//corner color
_videoThumbnailSelectionView.cornerColor = [UIColor whiteColor];
//corner radius
_videoThumbnailSelectionView.cornerRadius = 8.0;
//corner thickness
_videoThumbnailSelectionView.cornerInsets = UIEdgeInsetsMake(6.0, 6.0, 6.0, 6.0);
//called when selection changes
_videoThumbnailSelectionView.onUpdatedImage = ^(UIImage *image){
//do stuff with the image
};
Swift
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
//after customization, call this to load your asset.
thumbnailSelectionView.loadVideo(asset)
}
Obj-c
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
//after customization, call this to load your asset.
[_videoThumbnailSelectionView loadVideo:asset];
}
如果您需要加载新的视频,您必须在此调用 load 之前执行此操作。
Swift
thumbnailSelectionView.deleteVideo()
Obj-c
[_videoThumbnailSelectionView deleteVideo];
确保在构建设置中启用了“定义模块”。
VideoThumbnailSelectionView 在 MIT 许可下可用。
Sarp Solakoglu - [email protected]