Clear all annotations (Text, Shapes, Paths, etc) from Image Editor
18 Dec 20211 minute to read
By invoking the ClearAnnotations
method of SfImageEditor, you can clear all the annotations (Text, Shapes, Path, and CustomView) added in the image editor without resetting the other edits (Rotation, Flip, Crop, Effects, etc).
The following code sample demonstrates this.
public partial class ViewController : UIViewController
{
SfImageEditor imageEditor;
...
public override void ViewDidLoad()
{
base.ViewDidLoad();
imageEditor = new SfImageEditor();
imageEditor.Frame = new CGRect(0, 50, this.View.Frame.Width, this.View.Frame.Height - 100);
imageEditor.Image = UIImage.FromBundle("EditorBuilding1.png");
View.AddSubview(imageEditor);
UIButton ClearAnnotations = new UIButton();
ClearAnnotations.SetTitle("Clear Annotations", UIControlState.Normal);
ClearAnnotations.BackgroundColor = UIColor.LightGray;
ClearAnnotations.TouchDown += ClearAnnotations_TouchDown;
ClearAnnotations.Frame = new CGRect(0, this.View.Frame.Height - 50, this.View.Frame.Width, 50);
View.AddSubview(ClearAnnotations);
}
private void ClearAnnotations_TouchDown(object sender, EventArgs e)
{
imageEditor.ClearAnnotations();
}
}