我正致力于在图片上添加文字。我发现CLImageEditor工具非常好。但我只想使用添加自己主题的文本工具。所以我可以在我的应用程序中使用该工具。或者我可以在我的应用程序中使用的任何其他工具。
答案 0 :(得分:1)
您可以为每个工具执行此操作。
CLImageToolInfo *tool = [editor.toolInfo subToolInfoWithToolName:@"CLToneCurveTool" recursive:NO];
tool.available = NO; // if available is set to NO, it is removed from the menu view.
答案 1 :(得分:1)
不,你不能直接打开一个子菜单。可能会在https://github.com/yackle/CLImageEditor/issues
向他们提出问题如果您只想显示几个选项,或者想要自定义项目位置,可以这样做:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
CLImageEditor *editor = [[CLImageEditor alloc] initWithImage:image];
editor.delegate = self;
CLImageToolInfo *tool1 = [editor.toolInfo subToolInfoWithToolName:@"CLAdjustmentTool" recursive:NO];
CLImageToolInfo *tool2 = [editor.toolInfo subToolInfoWithToolName:@"CLBlurTool" recursive:NO];
CLImageToolInfo *tool3 = [editor.toolInfo subToolInfoWithToolName:@"CLRotateTool" recursive:NO];
CLImageToolInfo *tool4 = [editor.toolInfo subToolInfoWithToolName:@"CLToneCurveTool" recursive:NO];
tool1.available = NO;
tool2.available = NO;
tool3.available = NO;
tool4.available = NO;
[picker pushViewController:editor animated:YES];
}
答案 2 :(得分:0)
//First disable all the tools like below but the one you need.
var tool = editor.toolInfo.subToolInfoWithToolName("CLRotateTool", recursive: false)
tool.available = false
//replace below 4 functions in CLImageEditorView Controller
- (void)setMenuView
{
CGFloat x = 0;
CGFloat W = 70;
CGFloat H = _menuView.height;
int toolCount = 0;
CGFloat padding = 0;
for(CLImageToolInfo *info in self.toolInfo.sortedSubtools){
if(info.available){
toolCount++;
}
}
CGFloat diff = _menuView.frame.size.width - toolCount * W;
if (0<diff && diff<2*W) {
padding = diff/(toolCount+1);
}
for(CLImageToolInfo *info in self.toolInfo.sortedSubtools){
if(!info.available){
continue;
}
CLToolbarMenuItem *view = [CLImageEditorTheme menuItemWithFrame:CGRectMake(x+padding, 0, W, H) target:self action:@selector(tappedMenuView:) toolInfo:info];
[_menuView addSubview:view];
x += W+padding;
[self tappedMenuView:view];
}
_menuView.contentSize = CGSizeMake(MAX(x, _menuView.frame.size.width+1), 0);
}
- (IBAction)pushedCancelBtn:(id)sender
{
_imageView.image = _originalImage;
[self resetImageViewFrame];
self.currentTool = nil;
[self pushedCloseBtn:nil];
}
- (IBAction)pushedDoneBtn:(id)sender
{
self.view.userInteractionEnabled = NO;
[self.currentTool executeWithCompletionBlock:^(UIImage *image, NSError *error, NSDictionary *userInfo) {
if(error){
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:error.localizedDescription delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}
else if(image){
_originalImage = image;
_imageView.image = image;
[self resetImageViewFrame];
self.currentTool = nil;
}
self.view.userInteractionEnabled = YES;
[self pushedFinishBtn:nil];
}];
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.title = self.toolInfo.title;
self.view.clipsToBounds = YES;
self.view.backgroundColor = self.theme.backgroundColor;
self.navigationController.view.backgroundColor = self.view.backgroundColor;
if([self respondsToSelector:@selector(automaticallyAdjustsScrollViewInsets)]){
self.automaticallyAdjustsScrollViewInsets = NO;
}
if([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]){
self.navigationController.interactivePopGestureRecognizer.enabled = NO;
}
[self initNavigationBar];
[self initMenuScrollView];
[self initImageScrollView];
if(_imageView==nil){
_imageView = [UIImageView new];
[_scrollView addSubview:_imageView];
[self refreshImageView];
}
[self setMenuView];
}
答案 3 :(得分:0)
您不能直接打开子菜单。
我创建了用于删除子工具的卸妆功能。雨燕4.2
private func removeTools(tools: [String]) {
tools.forEach {
guard let imageEditor = self.imageEditor else { return }
let tool = imageEditor.toolInfo.subToolInfo(withToolName: $0, recursive: false)
tool?.available = false
}
}
您可以这样打电话;
removeTools(tools: ["CLFilterTool", "CLEffectTool"])