PSPDFAnnotationStyleManager

@protocol PSPDFAnnotationStyleManager

The style manager will save UI-specific properties for annotations and apply them after creation. It also offers a selection of user-defined styles. There are three categories: Last used, key-specific and generic styles.

  • When annotations are changed and this is enabled, the defaults are updated accordingly. This defaults to YES.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic)
        BOOL shouldUpdateDefaultsForAnnotationChanges;

    Swift

    var shouldUpdateDefaultsForAnnotationChanges: Bool { get set }
  • Set default annotation styles. This is the perfect place to set your own default annotation styles.

    Declaration

    Objective-C

    - (void)setupDefaultStylesIfNeeded;

    Swift

    func setupDefaultStylesIfNeeded()
  • Keeps a list of style keys we want to listen to (like color or lineWidth). - note: If you want to disable automatic style saving, set this to nil.

    Declaration

    Objective-C

    @property (readwrite, copy, atomic, nullable) NSSet<NSString *> *styleKeys;

    Swift

    var styleKeys: Set
  • Returns the annotation styles, for the given key. Might return nil if there isn’t anything saved yet.

    Declaration

    Objective-C

    - (nullable NSArray<PSPDFAnnotationStyle *> *)stylesForKey:
        (nonnull NSString *)key;

    Swift

    func styles(forKey key: String) -> [PSPDFAnnotationStyle]?
  • Adds a style on the key store.

    Declaration

    Objective-C

    - (void)addStyle:(nonnull PSPDFAnnotationStyle *)style
              forKey:(nonnull NSString *)key;

    Swift

    func add(_ style: PSPDFAnnotationStyle, forKey key: String)
  • Removes a style from the key store.

    Declaration

    Objective-C

    - (void)removeStyle:(nonnull PSPDFAnnotationStyle *)style
                 forKey:(nonnull NSString *)key;

    Swift

    func remove(_ style: PSPDFAnnotationStyle, forKey key: String)
  • Returns default presets for a given key and type. Either presets set via setDefaultPresets:forKey:type:, or suitable internal defaults. - see: presetsForKey:type: - note: The implementation should be thread safe.

    Declaration

    Objective-C

    - (nullable NSArray<__kindof PSPDFModel *> *)
    defaultPresetsForKey:(nonnull PSPDFAnnotationString)key
                    type:(nonnull NSString *)type;

    Swift

    func defaultPresets(forKey key: PSPDFAnnotationString, type: String) -> [PSPDFModel]?
  • Sets default presets for a given key and type. The set default presets shoiuld be stored in memory only and set on every app restart. - see: setPresets:forKey:type: - note: The implementation should be thread safe.

    Declaration

    Objective-C

    - (void)setDefaultPresets:(nullable NSArray<__kindof PSPDFModel *> *)presets
                       forKey:(nonnull PSPDFAnnotationString)key
                         type:(nonnull NSString *)type;

    Swift

    func setDefaultPresets(_ presets: [PSPDFModel]?, forKey key: PSPDFAnnotationString, type: String)
  • Get the color presets for a specified key and preset type. Returns the set presets or appropriate default presets if no custom presets were set. Returns an array of objects corresponding to the preset type (e.g, PSPDFColorPreset). @property key The annotation string, e.g. PSPDFAnnotationStringFreeText. @property type The preset type, e.g. PSPDFStyleManagerColorPresetKey (see PSPDFAnnotationStyleManager.h).

    Declaration

    Objective-C

    - (nullable NSArray<__kindof PSPDFModel *> *)
    presetsForKey:(nonnull PSPDFAnnotationString)key
             type:(nonnull NSString *)type;

    Swift

    func presets(forKey key: PSPDFAnnotationString, type: String) -> [PSPDFModel]?
  • Updates the presets for the specified key and preset type. @property presets An array of presets to save. They object must conform to NSCoding. Setting nil removes the presets from storage and reverts to the default presets (if set). @property key The annotation string, e.g. PSPDFAnnotationStringFreeText. @property type The preset type, e.g. PSPDFStyleManagerColorPresetKey (see PSPDFAnnotationStyleManager.h).

    Declaration

    Objective-C

    - (void)setPresets:(nullable NSArray<__kindof PSPDFModel *> *)presets
                forKey:(nonnull PSPDFAnnotationString)key
                  type:(nonnull NSString *)type;

    Swift

    func setPresets(_ presets: [PSPDFModel]?, forKey key: PSPDFAnnotationString, type: String)
  • Checks if the preset at the given index differs from its default value. @property presets Index of preset in the preset array. @property key The annotation string, e.g. PSPDFAnnotationStringFreeText. @property type The preset type, e.g. PSPDFStyleManagerColorPresetKey (see PSPDFAnnotationStyleManager.h).

    Declaration

    Objective-C

    - (BOOL)isPresetModifiedAtIndex:(NSUInteger)index
                             forKey:(nonnull PSPDFAnnotationString)key
                               type:(nonnull NSString *)type;

    Swift

    func isPresetModified(at index: UInt, forKey key: PSPDFAnnotationString, type: String) -> Bool
  • Resets the preset at the given index to its default value. @property presets Index of preset in the preset array. @property key The annotation string, e.g. PSPDFAnnotationStringFreeText. @property type The preset type, e.g. PSPDFStyleManagerColorPresetKey (see PSPDFAnnotationStyleManager.h).

    Declaration

    Objective-C

    - (BOOL)resetPresetAtIndex:(NSUInteger)idx
                        forKey:(nonnull PSPDFAnnotationString)key
                          type:(nonnull NSString *)type;

    Swift

    func resetPreset(at idx: UInt, forKey key: PSPDFAnnotationString, type: String) -> Bool