General

libDeusPrefs is a preferences library I’ve created to reduce the amount of copy-pasting I have to do each time I need to make a preference bundle. Supports iOS 13 to 14 currently.

Documentation website generated using Docuowl, since I hate HTML.

Installing libDeusPrefs to Theos
  • Pre-Compiled Method 1

  • Avoid having to compile libDeusPrefs

    • Step 1

    • Download libDeusPrefs bundle from Chariz

    • Step 2

    • Copy /usr/lib/libDeusPrefs.dylib to $THEOS/lib/

    • Step 3

    • Download libDeusPrefs.h from GitHub and place in $THEOS/include/

  • Compiling From Source Method 2

  • Compile libDeusPrefs library manually

    • Step 1

    • Download libDeusPrefs’s source code from GitHub

    • Step 2

    • Compile with make do install-to-theos

Adding libDeusPrefs to a Project
  • Step 1

  • Add the libDeusPrefs library to your preference bundle makefile:

    1prefs_LIBRARIES = DeusPrefs
    
  • Step 2

  • Add com.lacertosusrepo.libDeusPrefs to the Depends: field of your control file:

    1Depends: com.lacertosusrepo.libdeusprefs (>= 1.0)
    
Previewing Features
  • Pre-Compiled Method 1

  • Avoid having to compile libDeusPrefs

    • Step 1

    • Download libDeusPrefsExample bundle from GitHub

    • Step 2

    • Copy libDeusPrefsExample.bundle to /Library/PreferenceBundles/ on your device

    • Step 3

    • Copy libDeusPrefsExample.plist to /Library/PreferenceLoader/Preferences on your device

    • Step 4

    • Restart the settings app

  • Compiling From Source Method 2

  • Compile libDeusPrefsExample bundle manually

    • Step 1

    • Download libDeusPrefs’s source code from GitHub

    • Step 2

    • Compile with make do install-bundle

License

    Licensed under the Apache License.

    Cells

    Improvements to the basic preference cells and two whole new cells.

    LDInputSegmentTableCell

    The usual segment cell but with a button allowing for user input. Generally used for inputting a custom integer.

    Keys
    • inputTitle string

    • Title for the input alert view.

    • inputMessage string

    • Message for the input alert view.

    • localizationTable string

    • Name of localization table to lookup localization key.

    Declaration

    1@interface LDInputSegmentTableCell : PSSegmentTableCell
    2@end
    

    Example Usage

     1<dict>
     2	<key>cell</key>
     3	<string>PSSegmentCell</string>
     4	<key>cellClass</key>
     5	<string>LDInputSegmentTableCell</string>
     6	<key>inputTitle</key>
     7	<string>Input Alert Title</string>
     8	<key>inputMessage</key>
     9	<string>Your input message here!</string>
    10	<key>defaults</key>
    11	<string>com.company.tweak</string>
    12	<key>key</key>
    13	<string>key</string>
    14	<key>default</key>
    15	<string>2</string>
    16	<key>validTitles</key>
    17	<array>
    18		<string>One Option</string>
    19		<string>Two Option</string>
    20	</array>
    21	<key>validValues</key>
    22	<array>
    23		<integer>1</integer>
    24		<integer>2</integer>
    25	</array>
    26	<key>PostNotification</key>
    27	<string>com.company.tweak/ReloadPrefs</string>
    28</dict>
    

    LDLabeledSegmentTableCell

    Your favorite segmented table cell but with a label centered above it.

    Keys
    • label string

    • String to be displayed above the segment cell.

    • localizationTable string

    • Name of localization table to lookup localization key.

    Declaration

    1@interface LDLabeledSegmentTableCell : PSSegmentTableCell
    2@end
    

    Example Usage

     1<dict>
     2	<key>cell</key>
     3	<string>PSSegmentCell</string>
     4	<key>cellClass</key>
     5	<string>LDLabeledSegmentTableCell</string>
     6	<key>defaults</key>
     7	<string>com.company.tweak</string>
     8	<key>key</key>
     9	<string>key</string>
    10	<key>label</key>
    11	<string>Segment Label</string>
    12	<key>default</key>
    13	<string>0</string>
    14	<key>validTitles</key>
    15	<array>
    16		<string>One Option</string>
    17		<string>Two Option</string>
    18	</array>
    19	<key>validValues</key>
    20	<array>
    21		<integer>1</integer>
    22		<integer>2</integer>
    23	</array>
    24	<key>PostNotification</key>
    25	<string>com.company.tweak/ReloadPrefs</string>
    26</dict>
    

    LDLabeledSliderCell

    Your favorite slider cell but with a label centered above it. The value label can also be tapped to enter a value manually.

    Keys
    • label string

    • String to be displayed above the segment cell.

    • localizationTable string

    • Name of localization table to lookup localization key.

    Declaration

    1@interface LDLabeledSliderCell : PSSliderTableCell
    2@end
    

    Example Usage

     1<dict>
     2	<key>cell</key>
     3	<string>PSSliderCell</string>
     4	<key>cellClass</key>
     5	<string>LDLabeledSliderCell</string>
     6	<key>defaults</key>
     7	<string>com.company.tweak</string>
     8	<key>key</key>
     9	<string>key</string>
    10	<key>label</key>
    11	<string>Slider Label</string>
    12	<key>default</key>
    13	<string>5</string>
    14	<key>min</key>
    15	<string>0</string>
    16	<key>max</key>
    17	<string>10</string>
    18	<key>PostNotification</key>
    19	<string>com.company.tweak/ReloadPrefs</string>
    20</dict>
    

    LDStylePickerCell

    A style picker just like Apple’s light/dark mode picker. Useful for visually conveying options.

    Keys
    • options array

    • Array of options to list. Contains dictionaries with keys listed below.

      • label string

      • String to be displayed below the option’s image.

      • appearanceOption string/integer

      • Value that will be saved when the option is selected.

      • image string

      • Name of the image to be displayed for the option.

      • imageAlt string

      • Name of an alternative image to be displayed when the device is in dark mode. This is an optional key, if ignored the normal image will be used in both light & dark mode.

      • id string

      • Identifier for the option view.

    • infoMessage string

    • Message for the info alert.

    • localizationTable string

    • Name of localization table to lookup localization key.

    Declaration

    1@interface LDStylePickerCell : PSTableCell
    2@end
    

    Example Usage

     1<dict>
     2	<key>cell</key>
     3	<string>PSTableCell</string>
     4	<key>cellClass</key>
     5	<string>LDStylePickerCell</string>
     6	<key>defaults</key>
     7	<string>com.company.tweak</string>
     8	<key>key</key>
     9	<string>key</string>
    10	<key>default</key>
    11	<string>appearanceOption</string>
    12	<key>localizationTable</key>
    13	<string>Root</string>
    14	<key>PostNotification</key>
    15	<string>com.company.tweak/ReloadPrefs</string>
    16	<key>options</key>
    17	<array>
    18		<dict>
    19			<key>label</key>
    20			<string>Option One</string>
    21			<key>appearanceOption</key>
    22			<string>optionOneValue</string>
    23			<key>image</key>
    24			<string>imageForOptionOne</string>
    25		</dict>
    26
    27		<dict>
    28			<key>label</key>
    29			<string>Option Two</string>
    30			<key>appearanceOption</key>
    31			<string>optionTwoValue</string>
    32			<key>image</key>
    33			<string>imageForOptionTwo</string>
    34			<key>imageAlt</key>
    35			<string>imageAlternativeForOptionTwo</string>
    36		</dict>
    37	</array>
    38</dict>
    

    LDSwitchWithInfoCell

    Your favorite switch cell but with button to show an alert with more information on the option.

    Keys
    • infoTile string

    • Title for the info alert.

    • infoMessage string

    • Message for the info alert.

    • infoAlternativeStyle bool

    • Alternative style using the whole cell as a button for more information. A subtitle is displayed beneath the cell’s label which can be overridden using the cellSubtitleText key.

    • localizationTable string

    • Name of localization table to lookup localization key.

    Declaration

    1@interface LDSwitchWithInfoCell : PSSwitchTableCell
    2@end
    

    Example Usage

     1<dict>
     2	<key>cell</key>
     3	<string>PSSwitchCell</string>
     4	<key>cellClass</key>
     5	<string>LDSwitchWithInfoCell</string>
     6	<key>infoTitle</key>
     7	<string>Info Alert Title</string>
     8	<key>infoMessage</key>
     9	<string>Your info message here!</string>
    10	<key>defaults</key>
    11	<string>com.company.tweak</string>
    12	<key>key</key>
    13	<string>key</string>
    14	<key>label</key>
    15	<string>Switch Label</string>
    16	<key>default</key>
    17	<false/>
    18	<key>PostNotification</key>
    19	<string>com.company.tweak/ReloadPrefs</string>
    20</dict>
    

    LDTimeIntervalPickerCell

    A cell allowing users to select a time interval in hours, minutes, & seconds. The value/default is saved in seconds.

    Keys
    • label string

    • String used for the popup title and cell label.

    • default integer

    • This value should be the total seconds of whatever default you chose. For example, 1 hour should be 3600 seconds.

    Declaration

    1@interface LDTimeIntervalPickerCell : PSTableCell
    2@end
    

    Example Usage

     1<dict>
     2	<key>cell</key>
     3	<string>PSButtonCell</string>
     4	<key>cellClass</key>
     5	<string>LDTimeIntervalPickerCell</string>
     6	<key>defaults</key>
     7	<string>com.company.tweak</string>
     8	<key>key</key>
     9	<string>key</string>
    10	<key>label</key>
    11	<string>Set Time Interval</string>
    12	<key>default</key>
    13	<integer>120</integer>
    14	<key>PostNotification</key>
    15	<string>com.company.tweak/ReloadPrefs</string>
    16</dict>
    

    Views

    Custom views. Don’t forget to import libDeusPrefs.h.

    LDAnimatedTitleView

    An animated title in the navigation bar that slides up when the user scrolls down.

    Parameters
    • title string

    • String used for the label.

    • color UIColor

    • Color of the label.

    • minimumOffset float

    • Minimum scroll view offset before the label animates.

    Declaration

    1-(instancetype)initWithTitle:(NSString *)title textColor:(UIColor *)color minimumScrollOffsetRequired:(CGFloat)minimumOffset;
    

    Example Usage

     1-(void)viewDidAppear:(BOOL)animated {
     2	[super viewDidAppear:animated];
     3
     4	if(!self.navigationItem.titleView) {
     5		LDAnimatedTitleView *animatedTitleView = [[LDAnimatedTitleView alloc] initWithTitle:@"Your Title" textColor:[UIColor redColor] minimumScrollOffsetRequired:20];
     6		self.navigationItem.titleView = animatedTitleView;
     7	}
     8}
     9
    10-(void)scrollViewDidScroll:(UIScrollView *)scrollView {
    11	if([self.navigationItem.titleView respondsToSelector:@selector(adjustLabelPositionToScrollOffset:)]) {
    12		[(LDAnimatedTitleView *)self.navigationItem.titleView adjustLabelPositionToScrollOffset:scrollView.contentOffset.y];
    13	}
    14}
    

    LDHeaderView

    A table header including an icon, a title label, and randomly selected subtitle label. Can be configured using a dictionary of keys for more options.

    Parameters
    • title string

    • String used for the header’s title label.

    • subtitles string

    • Array of strings used for the header’s subtitle. A random string is selected from the array each time the preference pane is loaded.

    • bundle NSBundle

    • Bundle to retrieve the icon from if the icon’s file name is specified in the options dictionary.

    • options NSDictionary

    • Dictionary of keys and corresponding values containing options used to configure the header view. A list of keys can be found below.

      • LDHeaderOptionIconFileName string

      • Name of the large icon file (should be 225x225px) or alternatively an SFSymbol image name can be used instead. If no icon is desired ignore this key.

      • LDHeaderOptionTitleFontSize float

      • Font size of the title label. Default is 35.

      • LDHeaderOptionTitleFontColor UIColor

      • Font color of the title label.

      • LDHeaderOptionSubtitleFontSize float

      • Font size of the subtitle label. Default is 13.

      • LDHeaderOptionSubtitleFontColor UIColor

      • Font color of the subtitle label.

      • LDHeaderOptionAddInterpolatingMotion bool

      • Adds slight interpolating motion when the device is moved. Default is NO.

      • LDHeaderOptionAddMaterialBackground bool

      • Adds a blurred background to the header. Use the LDHeaderOptionBackgroundImageFileName key to define an image to be blurred. Default is NO.

      • LDHeaderOptionBackgroundImageFileName string

      • Define the name of the image file to be blurred behind the material view. Alternatively, set to ‘DeviceWallpaper’ to use the wallpaper of the device.

      • LDHeaderOptionHeaderStyle LDHeaderStyle

      • Set the style of the header view. Must be converted to a NSNumber. Default is LDHeaderStyleVertical.

        • LDHeaderStyleVertical

        • Vertical style with the icon center above the title and subtitle.

        • LDHeaderStyleHorizontalIconRight

        • Horizontal style with the icon to the right of the title and subtitle.

        • LDHeaderStyleHorizontalIconLeft

        • Horizontal style with the icon to the left of the title and subtitle.

    Declaration

    1-(instancetype)initWithTitle:(NSString *)title subtitles:(NSArray<NSString *> *)subtitles bundle:(NSBundle *)bundle options:(NSDictionary<NSString *, id> *)options;
    

    Example Usage

     1-(void)viewDidLoad {
     2	[super viewDidLoad];
     3
     4	NSArray *subtitles = @[@"Array of subtitles", @"A random one will be selected"];
     5	NSDictionary *options @{LDHeaderOptionIconFileName : @"largeIcon", LDHeaderOptionTitleFontSize : @25};
     6
     7	LDHeaderView *header = [[LDHeaderView alloc] initWithTitle:@"Example Title" subtitles:subtitles bundle:[self bundle] options:options];
     8	header.frame = CGRectMake(0, 0, header.bounds.size.width, 135);
     9	self.table.tableHeaderView = header;
    10}
    

    ParvusConstraint

    Additions to NSLayoutConstraint that allows for (limited) easier constraints.

    ld_constrainView

    Constrain specified anchors from one view to another with optional constants.

    Parameters
    • primaryView UIView

    • View to be anchored.

    • secondaryView UIView

    • View to be anchored to.

    • anchors string

    • Anchors to add constraints to. Abbreviations are used and each should be separated by a string.

      • w

      • Width Anchor

      • h

      • Height Anchor

      • x

      • Center X Anchor

      • y

      • Center Y Anchor

      • top

      • Top Anchor

      • bottom

      • Bottom Anchor

      • leading

      • Leading Anchor

      • trailing

      • Trailing Anchor

    • constants LDLayoutConstants

    • Struct with constants for each anchor. Multiple helper functions to allow to create LDLayoutConstants.

    • Return Value array

    • Array of constraints added to the primaryView. Each constraint’s identifier is set to the corresponding anchor used for the constraint.

    Declaration

    1+(NSArray <NSLayoutConstraint *>*)ld_constrainView:(UIView *)primaryView toView:(UIView *)secondaryView anchors:(NSString *)anchors constants:(LDLayoutConstants)constants;
    2+(NSArray <NSLayoutConstraint *>*)ld_constrainView:(UIView *)primaryView toView:(UIView *)secondaryView anchors:(NSString *)anchors;
    

    Example Usage

    1[NSLayoutConstraint ld_constrainView:firstView toView:otherView anchors:@"w, h" constants:LDSizeConstantsMake(100, 50)];
    2
    3[NSLayoutConstraint ld_constrainView:firstView toView:otherView anchors:@"x, leading, trailing"];
    

    ld_centerView

    Constrain view to the center X and Y anchors of a specified view. Also add height and width anchors.

    Parameters
    • primaryView UIView

    • View to be anchored.

    • secondaryView UIView

    • View to be anchored to.

    • constants LDLayoutConstants

    • Struct with constants for each anchor. Multiple helper functions to allow to create LDLayoutConstants.

    • Return Value array

    • Array of constraints added to the primaryView. Each constraint’s identifier is set to the corresponding anchor used for the constraint.

    Declaration

    1+(NSArray <NSLayoutConstraint *>*)ld_centerView:(UIView *)primaryView inView:(UIView *)secondaryView constants:(LDLayoutConstants)constants;
    

    Example Usage

    1[NSLayoutConstraint ld_centerView:firstView inView:otherView constants:LDSizeConstantsMake(200, 40)];
    

    ld_sizeView

    Constrain view’s width and height anchors to constants.

    Parameters
    • primaryView UIView

    • View to be anchored.

    • secondaryView UIView

    • View to be anchored to.

    • constants LDLayoutConstants

    • Struct with constants for each anchor. Multiple helper functions to allow to create LDLayoutConstants.

    • Return Value array

    • Array of constraints added to the primaryView. Each constraint’s identifier is set to the corresponding anchor used for the constraint.

    Declaration

    1+(NSArray <NSLayoutConstraint *>*)ld_sizeView:(UIView *)primaryView inView:(UIView *)secondaryView constants:(LDLayoutConstants)constants;
    

    Example Usage

    1[NSLayoutConstraint ld_sizeView:firstView inView:otherView constants:LDSizeConstantsMake(96, 82)];
    

    LDLayoutConstants

    Struct with constants for each anchor. Multiple helper functions to allow to create LDLayoutConstants.

    Parameters
    • width float

    • Width anchor constant.

    • height float

    • Height anchor constant.

    • x float

    • Center X anchor constant.

    • y float

    • Center Y anchor constant.

    • top float

    • Top anchor constant.

    • bottom float

    • Bottom anchor constant.

    • leading float

    • Leading anchor constant.

    • trailing float

    • Trailing anchor constant.

    • Return Value LDLayoutConstants

    • Constants to be used with ParvusConstraint.

    Functions
    • LDLayoutConstantsMake()

    • Function with parameters for each constant. Very long.

    • LDSelectConstantsMake()

    • Function using a dictionary to set only specific constants.

      • w

      • Width Constant

      • h

      • Height Constant

      • x

      • Center X Constant

      • y

      • Center Y Constant

      • tp

      • Top Constant

      • b

      • Bottom Constant

      • l

      • Leading Constant

      • tl

      • Trailing Constant

    • LDSizeConstantsMake()

    • Function with parameters only for width and height constants.

    • LDEdgeConstantsMake()

    • Function with parameters for top, bottom, leading, and trailing constants.

    Declaration

     1struct LDLayoutConstants {
     2  CGFloat width;
     3  CGFloat height;
     4  CGFloat x;
     5  CGFloat y;
     6  CGFloat top;
     7  CGFloat bottom;
     8  CGFloat leading;
     9  CGFloat trailing;
    10};
    

    Example Usage

    1LDLayoutConstants constants;
    2constants.width = 100;
    3constants.top = -5;
    4constants.y = 23;
    

    Functions

    1LDLayoutConstants LDLayoutConstantsMake(CGFloat width, CGFloat height, CGFloat x, CGFloat y, CGFloat top, CGFloat bottom, CGFloat leading, CGFloat trailing);
    2LDLayoutConstants LDSelectConstantsMake(NSDictionary <NSString *, NSNumber *>*constantsDict);
    3LDLayoutConstants LDSizeConstantsMake(CGFloat width, CGFloat height);
    4LDLayoutConstants LDEdgeConstantsMake(CGFloat top, CGFloat bottom, CGFloat leading, CGFloat trailing);