On this page
Guides
Cloud Border Style for Annotations
Users are allowed to set the border style of rectangular, circular, and polygonal annotations to a cloud-like pattern. The border style can also be changed between solid lines, dashed lines, or the cloud style. ComPDFKit provides convenient APIs for setting the cloud border style for annotations, along with demo demonstrations.
Here is an example code for adding a cloud-style border to a rectangular annotation:
swift
// Dotted line style
let border = CPDFBorder(style: .dashed, lineWidth: 1, dashPattern: [2, 1])
let square = CPDFSquareAnnotation(document: document)
// Set the annotation properties.
square?.bounds = CGRect(x: 400, y: 200, width: 80, height: 300)
square?.color = UIColor.green
square?.interiorColor = UIColor.purple
square?.opacity = 1.0
square?.interiorOpacity = 1.0
// Set a solid or dashed border style
square?.border = border
// Set the cloud border style
let borderEffect = CPDFBorderEffect()
borderEffect?.borderEffectType = .cloudy
borderEffect?.intensityType = .two
square?.borderEffect = borderEffect
page.addAnnotation(square!)
objective-c
// Dotted line style
CPDFBorder *border = [[CPDFBorder alloc] initWithStyle:CPDFBorderStyleDashed
lineWidth:1
dashPattern:@[@(2), @(1)]];
CPDFSquareAnnotation *square = [[CPDFSquareAnnotation alloc] initWithDocument:document];
// Set the annotation properties.
square.bounds = CGRectMake(400, 200, 80, 300);
square.color = [UIColor greenColor];
square.interiorColor = [UIColor purpleColor];
square.opacity = 1.0;
square.interiorOpacity = 1.0;
// Set a solid or dashed border style
square.border = border;
// Set the cloud border style
CPDFBorderEffect *borderEffect = [[CPDFBorderEffect alloc] init];
borderEffect.intensityType = CPDFIntensityTypeTwo;
borderEffect.borderEffectType = CPDFBorderEffectTypeCloudy;
square.borderEffect = borderEffect
[page addAnnotation:square];
Cloud Border style Type Enumeration
Name | Description |
---|---|
CPDFIntensityTypeZero | The influence intensity ranges from 0 to 2, and when it is 0, it is a solid line |
CPDFIntensityTypeOne | |
CPDFIntensityTypeTwo |
Name | Description |
---|---|
CPDFBorderEffectTypeSolid | The border style style is a solid line |
CPDFBorderEffectTypeCloudy | The border style style is cloud style |