Interface Class Name | Description |
TAVEditor | SDK operation entry class. |
ITAVStickerManager | Sticker operation entry class. |
TAVMediaStickerItem | Sticker data model class. |
TAVEditor to obtain it directly:// Get TAVEditor APINSString *bundlePath = [[NSBundle mainBundle] pathForResource:@"LightCore" ofType:@"bundle"];self.tavEditor = [[TAVEditor alloc] initWithRenderSize:CGSizeZero assetsPath:bundlePath];// Get sticker operation interfaceid<ITAVStickerManager> stickerManager = [self.tavEditor getStickerManager];
TAVMediaStickerItem, so before operating on stickers, you must first have aTAVMediaStickerItem object,TAVMediaStickerItemsetTimeRange. If not set, it defaults to the entire asset duration.// 1. Create a text stickerNSString *stickerPath = [[NSBundle mainBundle] pathForResource:@"text_default" ofType:@"bundle"];TAVMediaStickerItem *stickerItem = [stickerManager createStickerItem:textPath stickerType:TAVStickerTypeText];// Set text sticker font// Get font object. fontPath is the font file path; fontFamily and fontStyle can be empty strings if unknownPAGFont *pagFont = [PAGFont RegisterFont:fontPathfamily:fontFamilystyle:fontStyle];stickerItem.font = pagFont;stickerItem.timeRange = timerange;// 2. Create an image stickerNSString *stickerPath = [[NSBundle mainBundle] pathForResource:@"image_default" ofType:@"bundle"];TAVMediaStickerItem *stickerItem = [stickerManager createStickerItem:stickerPath stickerType:TAVStickerTypeImage];// Set imageNSString *imagePath = ....;stickerItem.imageFilePath = imagePath;// 3. Create an animated sticker// This is a path pointing to main.pag. The sticker__plfttz_01.bundle directory contains the main.pag fileNSString *stickerPath = [[NSBundle mainBundle] pathForResource:@"sticker__plfttz_01" ofType:@"bundle"];TAVMediaStickerItem *stickerItem = [[TAVMediaStickerItem alloc] initWithStickerID:@"stickerPlfttz01Id" resourceInfoPath:stickerPath];
TAVStickerManager to load stickers.[stickerManager loadStickerItem:stickerItem];
@protocol ITAVStickerViewDataSource <NSObject>/// Return a sticker view for the given sticker object. Can inherit from TAVStickerView to customize controls/// - Parameter stickerItem: Sticker object- (TAVStickerView *)stickerViewWithStickerItem:(TAVMediaStickerItem *)stickerItem;@end- (void)setStickerViewDataSource:(id<ITAVStickerViewDataSource>)dataSource;
@interface MyStickerContentView : TAVStickerView/// ...Implement your own business logic@end#pragma mark - ITAVStickerViewDataSource- (TAVStickerView *)stickerViewWithStickerItem:(TAVMediaStickerItem *)stickerItem{// Custom sticker view must inherit from TAVStickerViewMyStickerContentView *stickerView = [[MyStickerContentView alloc] initWithStickerItem:stickerItem];return stickerView;}
@interface MyStickerContentView : TAVStickerContentView/// ...Implement your own business logic@end
TAVStickerManager in setStickerContentView to set the custom sticker container layout./// Bind the container view for adding stickers/// - Parameter stickerContentView: Must inherit from TAVStickerContentView- (void)setStickerContentView:(TAVStickerContentView *)stickerContentView;
// Set textstickerItem.text = @"";// Set fontPAGFont *pagFont = [PAGFont RegisterFont:fontPathfamily:fontFamilystyle:fontStyle];stickerItem.font = pagFont;
@property (nonatomic, copy) NSString *text; // Text content of the text sticker@property (nonatomic, strong, readonly) NSString *defaultText; // Default text of the text sticker@property (nonatomic, strong) UIColor *textColor; // Text color of the text sticker@property (nonatomic, strong) UIColor *bgColor; // Overall sticker background color@property (nonatomic, strong) PAGFont *pagFont; // Text font/// Stroke@property (nonatomic, assign) BOOL applyTextStroke; // Enable text stroke@property (nonatomic, assign) CGFloat textStrokeWidth; // Text stroke width@property (nonatomic, strong) UIColor *textStrokeColor; // Text stroke color/// Text background@property (nonatomic, strong) UIColor *textBgColor; // Text background color@property (nonatomic, assign) CGFloat textBgAlpha; // Text background opacity, range 0 - 1
// 2. Create an image stickerNSString *stickerPath = [[NSBundle mainBundle] pathForResource:@"image_default" ofType:@"bundle"];TAVMediaStickerItem *stickerItem = [[TAVMediaStickerItem alloc] initWithStickerID:@"imageDefaultId" resourceInfoPath:stickerPath];// Switch imageTAVStickerImageItem *imageItem = stickerItem.sticker.imageList.firstObject;NSString *imagePath = ....;imageItem.filePath = imagePath;
フィードバック