DCEDrawingLayer
The layers that contains DrawingItems. Users can add configurations for the DrawingItems via DCEDrawingLayer
- Objective-C
- Swift
@interface DCEDrawingLayerclass DCEDrawingLayer : NSObject
| Method Name | Description |
|---|---|
initWithId |
The constructor of the DCEDrawingLayer class. |
id |
Get the DrawingLayer ID of the DrawingLayer. |
drawingItems |
A list of DrawingItems. |
addDrawingItems |
Add a list of DrawingItems to the DrawingLayer. These DrawingItems will be appended to the DrawingItem list of the current DrawingLayer. |
setDrawingStyleId |
Set the DrawingStyle of the DrawingLayer by ID. |
setDrawingStyleId:state: |
Set the DrawingStyle of the DrawingLayer by ID. |
setDrawingStyleId:state:mediaType: |
Set the DrawingStyle of the DrawingLayer by ID. |
visible |
The property that stores the visibility of the DrawingLayer. |
initWithId
The constructor of the DCEDrawingLayer class. Initialize the instance of the DCEDrawingLayer class.
- Objective-C
- Swift
- (instancetype) initWithId:(NSInteger)id;init(id layerId: Int)
Parameters
id: Indicates the id of the layer.
Remarks
Please initialize the DrawingLayers via the following methods:
id
The ID of the DrawingLayer.
- Objective-C
- Swift
@property (assign, nonatomic) NSInteger layerId;var layerId: Int { get }
The ID can be one of the following:
DDN_LAYER_IDDBR_LAYER_IDDLR_LAYER_IDUSER_DEFINED_LAYER_BASE_ID
drawingItems
The property that stores all the DrawingItems on the layer. This property determines which DrawingItems will be displayed on the layer.
- Objective-C
- Swift
@property (nonatomic, strong, readwrite, nullable) NSArray<DrawingItem *> *drawingItems;var drawingItems: [DrawingItem]? { get set }
addDrawingItems
Add a list of DrawingItems to the DrawingLayer. These DrawingItems will be appended to the property drawingItems.
- Objective-C
- Swift
- (void) addDrawingItems:(NSArray<DrawingItem*>*)items;func addDrawingItems(_ items: [DrawingItem])
Parameters
items: A list of DrawingItems.
Code Snippet
- Objective-C
- Swift
// Create a new DrawingItem array. NSMutableArray<DrawingItem *> *array = [NSMutableArray array]; // You can append QuadDrawingItems, RectDrawingItems and TextDrawingItems in the array. // For example, we use QuadDrawingItems here. The quad data here is obtained from Dynamsoft Document Normalizer for (iDetectedQuadResult *detectedQuadResult in [StaticClass instance].quadArr) { iQuadrilateral *quad = detectedQuadResult.location; QuadDrawingItem *quadItem = [[QuadDrawingItem alloc] initWithQuad:quad]; [array addObject:quadItem]; } layer.drawingItems = array;// Create a new DrawingItem array. var array:[DrawingItem]? = [] // You can append QuadDrawingItems, RectDrawingItems and TextDrawingItems in the array. // For example, we use QuadDrawingItems here. The quad data here is obtained from Dynamsoft Document Normalizer for detectQuadResult in StaticClass.instance.quadArray{ let quad = detectQuadResult.location let quadItem = QuadDrawingItem.init(quad: quad) array?.append(quadItem) } // Assign the new DrawingItem array to the drawingItems. layer.drawingItems = array
setDrawingStyleId
Specify a style ID for all available DrawingItems.
- Objective-C
- Swift
- (void) setDrawingStyleId:(NSInteger)styleId;func setDrawingStyleId(_ styleId: Int)
Parameters
styleId: The style ID.
Code Snippet
- Objective-C
- Swift
[drawingLayer setDrawingStyleId:0];drawingLayer.setDrawingStyleId(0)
setDrawingStyleId:state:
Specify a style ID for the targeting DrawingItems. The stateis a filter of the DrawingItems. All the eligible DrawingItems will be changed to the input style.
- Objective-C
- Swift
- (void) setDrawingStyleId:(NSInteger)styleId state:(EnumDrawingItemState)state;func setDrawingStyleId(_ styleId: Int, state: EnumDrawingItemState)
Parameters
styleId: The style ID.
state: The state of the DrawingItem.
Code Snippet
- Objective-C
- Swift
[drawingLayer setDrawingStyleId:0 state:EnumDrawingItemStateSelected];drawingLayer.setDrawingStyleId(0, state:EnumDrawingItemState.selected)
setDrawingStyleId:state:mediaType:
Specify a style ID for the targeting DrawingItems. The state and mediaType are filters of the DrawingItems. All the eligible DrawingItems will be changed to the input style.
- Objective-C
- Swift
- (void) setDrawingStyleId:(NSInteger)styleId state:(EnumDrawingItemState)state mediaTypes:(NSArray*)mediaTypes;func setDrawingStyleId(_ styleId: Int, state: EnumDrawingItemState, mediaType: EnumDrawingItemMediaType)
Parameters
styleId: The style ID.
state: The state of the DrawingItem.
mediaType: The media type of the DrawingItem.
Code Snippet
- Objective-C
- Swift
[drawingLayer setDrawingStyleId:0 state:EnumDrawingItemStateSelected mediaType:@[@(EnumDrawingItemMediaTypeRectangle), @(EnumDrawingItemMediaTypeQuadrilateral)]];drawingLayer.setDrawingStyleId(0, state:EnumDrawingItemState.selected, mediaType:[EnumDrawingItemMediaType.quadrilateral.rawValue, EnumDrawingItemMediaType.rectangle.rawValue])
visible
The property that stores the visibility of the DrawingLayer.
- Objective-C
- Swift
@property (assign, nonatomic) BOOL visible;var visible: Bool { get set }
Remarks
When visible is true, the DrawingLayer is visible. Otherwise, the DrawingLayer is invisible.