NSString(UgiUiUtil) Category Reference

Overview

Extension methods for NSString.

Instance Methods

(NSString *_Nonnull) - trimWhitespace
 
Trim whitespace from the string More...
 
(BOOL) - isEqualToStringCaseInsensitive:
 
Do a case insensitive compare More...
 
(CGSize) - sizeWithFont:constrainedToSize:
 
Find the size of the string More...
 

Instance Method Documentation

◆ trimWhitespace()

- (NSString * _Nonnull) trimWhitespace


Trim whitespace from the string

Returns
Trimmed string

◆ isEqualToStringCaseInsensitive:()

- (BOOL) isEqualToStringCaseInsensitive: (NSString *_Nullable)  s


Do a case insensitive compare

Parameters
sString to compare to
Returns
YES if equal

◆ sizeWithFont:constrainedToSize:()

- (CGSize) sizeWithFont: (UIFont *_Nonnull)  font
constrainedToSize: (CGSize)  size 


Find the size of the string

Parameters
fontFont to use
sizeSize to constrain to
Returns
Text size
NSTimer(UgiUiUtil) Category Reference

Overview

Extension methods for NSTimer.

Class Methods

(NSTimer *_Nonnull) + scheduledTimerWithTimeIntervalUgi:repeats:block:
 
Create a timer to run a block repeatedly – added in iOS 10, so added "Ugi" to the name to not clash More...
 

Instance Method Documentation

◆ scheduledTimerWithTimeIntervalUgi:repeats:block:()

+ (NSTimer * _Nonnull) scheduledTimerWithTimeIntervalUgi: (NSTimeInterval)  seconds
repeats: (BOOL)  repeats
block: (nonnull void(^)(void))  block 


Create a timer to run a block repeatedly – added in iOS 10, so added "Ugi" to the name to not clash

Parameters
secondsInternval between runs
repeatsYES to repeat
blockBlock to run
Returns
The timer
UIColor(UgiUiUtil) Category Reference

Overview

Extension methods for UIColor.

Class Methods

(UIColor *_Nonnull) + colorFromHexString:
 
Make a color from a hex string More...
 

Instance Methods

(UIColor *_Nonnull) - moreTransparent:
 
Make a color more transparent More...
 
(UIColor *_Nonnull) - lighten:
 
Make a color lighter More...
 
(UIColor *_Nonnull) - darken:
 
Make a color darker More...
 
(double) - luminance:
 
Get the perceived luminance of a color More...
 
(NSString *) - toHexString
 Convert color to a hex string. More...
 

Instance Method Documentation

◆ colorFromHexString:()

+ (UIColor * _Nonnull) colorFromHexString: (NSString *_Nonnull)  hexString


Make a color from a hex string

Parameters
hexStringThe string
Returns
New color

◆ moreTransparent:()

- (UIColor * _Nonnull) moreTransparent: (float)  degree


Make a color more transparent

Parameters
degreeDegree to make the color more transparent
Returns
New color

◆ lighten:()

- (UIColor * _Nonnull) lighten: (float)  degree


Make a color lighter

Parameters
degreeDegree to lighten: 0 = white, 1 = no change
Returns
New color

◆ darken:()

- (UIColor * _Nonnull) darken: (float)  degree


Make a color darker

Parameters
degreeDegree to darken: 0 = black, 1 = no change
Returns
New color

◆ luminance:()

- (double) luminance: (float)  dummy


Get the perceived luminance of a color

Parameters
dummyUnused parameter required to defeat a strange iOS/Objective-C bug
Returns
Luminance (between 0 and 1)

◆ toHexString()

- (NSString *) toHexString

Convert color to a hex string.

Returns
hex string for the color
UIImage(UgiUiUtil) Category Reference

Overview

Extension methods for UIImage.

Instance Methods

(UIImage *_Nonnull) - colorImageWithColor:
 
Fill all the non-transparent parts of an image with a color More...
 
(UIImage *_Nonnull) - scaleImageToSize:
 
Scale an image More...
 
(UIImage *) - scaleImage:
 
Scale an image More...
 
(UIImage *) - scaleImageForDevice
 
Scale an image to the device scale More...
 

Instance Method Documentation

◆ colorImageWithColor:()

- (UIImage * _Nonnull) colorImageWithColor: (UIColor *_Nonnull)  color


Fill all the non-transparent parts of an image with a color

Parameters
colorColor to fill with
Returns
New image

◆ scaleImageToSize:()

- (UIImage * _Nonnull) scaleImageToSize: (CGSize)  size


Scale an image

Parameters
sizeNew image size
Returns
New image

◆ scaleImage:()

- (UIImage *) scaleImage: (CGFloat)  scale


Scale an image

Parameters
scaleScale factor
Returns
New image

◆ scaleImageForDevice()

- (UIImage *) scaleImageForDevice


Scale an image to the device scale

Returns
New image
UINavigationController(UgiUiUtil) Category Reference

Overview

Extension methods for UINavigationController.

Instance Methods

(NSArray< UIViewController * > *_Nullable) - popToViewControllerOfClass:animated:
 
Pop view controllers until a specific class is encountered More...
 
(BOOL) - canPopToViewControllerOfClass:
 
See if there is a view controller of a specific class on the stack More...
 

Instance Method Documentation

◆ popToViewControllerOfClass:animated:()

- (NSArray<UIViewController *> * _Nullable) popToViewControllerOfClass: (nonnull Class)  viewControllerClass
animated: (BOOL)  animated 


Pop view controllers until a specific class is encountered

Parameters
viewControllerClassView controller class to stop at
animatedYES to animate
Returns
View controllers popped

◆ canPopToViewControllerOfClass:()

- (BOOL) canPopToViewControllerOfClass: (nonnull Class)  viewControllerClass


See if there is a view controller of a specific class on the stack

Parameters
viewControllerClassView controller class to look for
Returns
YES if there is a view controller of the specific class
UITableView(UgiUiUtil) Category Reference

Overview

Extension methods for UITableView.

Instance Methods

(void) - setNeedsDisplayForAllVisibleCells
 
Call setNeedsDisplay for all visible cells
 
(void) - scrollToBottom
 
Scroll to the bottom of the table
 
(UITableViewCell *_Nonnull) - appendRow:
 
Append a row to the table More...
 
(void) - deleteRowAtIndex:
 
Delete a row from a table More...
 

Instance Method Documentation

◆ appendRow:()

- (UITableViewCell * _Nonnull) appendRow: (BOOL)  scrollToBottom


Append a row to the table

Parameters
scrollToBottomYES to scroll to the bottom of the list (to display the appended row)
Returns
UITableViewCell appended

◆ deleteRowAtIndex:()

- (void) deleteRowAtIndex: (int)  index


Delete a row from a table

Parameters
indexRow to delete
UIView(UgiUiUtil) Category Reference

Overview

Extension methods for UIView.

Instance Methods

(nonnull id) - showModal:
 
Show this view as a modal dialog More...
 
(void) - hideModal:
 
Show this view after it has been shown with showModal: More...
 
(void) - hideModal:withCompletion:
 
Show this view after it has been shown with showModal: More...
 
(nullable id) - findFirstResponder
 
Find the view's first responder More...
 
(nullable id) - superviewOfClass:
 
Find the first superview view of a specific class More...
 
(nullable id) - subviewOfClass:
 
Find the first subview view of a specific class More...
 
(float) - setWidthConstraint:
 
Set or modify the width constraint for a view More...
 
(float) - setHeightConstraint:
 
Set or modify the height constraint for a view More...
 
(void) - constrainToParentLeft:top:right:bottom:
 
Constrain a view to its parent More...
 
(nullable id) - traverseSubviews:withCompletion:
 
Enumerate all subviews More...
 
(void) - updateThemeColorsInChildren
 
Update any child views that use the theme colors
 
(void) - logViewTree:firstArg:
 
Log the tree of subviews, for debugging More...
 
(void) - logViewParents:firstArg:
 
Log the chain of superviews, for debugging More...
 

Types

typedef _Nullable id(^ UgiTraverseSubviewsCompletion) (id _Nonnull subview, int depth)
 Completion for traverseSubviews:
 

Protected Types

enum  UgiShowModalAnimationTypes { UgiModalBottom, UgiModalCenter, UgiModalCenterWithKeyboard }
 Type passed to showModal for the type of transition and the placement. More...
 

Instance Method Documentation

◆ showModal:()

- (nonnull id) showModal: (UgiShowModalAnimationTypes animationType


Show this view as a modal dialog

Parameters
animationTypeType of animation
Returns
id to pass to hideModal:

◆ hideModal:()

- (void) hideModal: (nonnull id)  idFromShowModal


Show this view after it has been shown with showModal:

Parameters
idFromShowModalID returned by showModal

◆ hideModal:withCompletion:()

- (void) hideModal: (nonnull id)  idFromShowModal
withCompletion: (nullable void(^)(void))  completion 


Show this view after it has been shown with showModal:

Parameters
idFromShowModalID returned by showModal
completionBlock to run when completed

◆ findFirstResponder()

- (nullable id) findFirstResponder


Find the view's first responder

Returns
First responder

◆ superviewOfClass:()

- (nullable id) superviewOfClass: (nonnull Class)  viewClass


Find the first superview view of a specific class

Parameters
viewClassView class to look for
Returns
The view

◆ subviewOfClass:()

- (nullable id) subviewOfClass: (nonnull Class)  viewClass


Find the first subview view of a specific class

Parameters
viewClassView class to look for
Returns
The view

◆ setWidthConstraint:()

- (float) setWidthConstraint: (float)  width


Set or modify the width constraint for a view

Parameters
widthNew width (or -1 to remove width constraint)
Returns
Previous width constraint constant

◆ setHeightConstraint:()

- (float) setHeightConstraint: (float)  height


Set or modify the height constraint for a view

Parameters
heightNew height (or -1 to remove height constraint)
Returns
Previous height constraint constant

◆ constrainToParentLeft:top:right:bottom:()

- (void) constrainToParentLeft: (float)  left
top: (float)  top
right: (float)  right
bottom: (float)  bottom 


Constrain a view to its parent

Parameters
leftConstraint for left, or -1 for none
topConstraint for left, or -1 for none
rightConstraint for left, or -1 for none
bottomConstraint for left, or -1 for none

◆ traverseSubviews:withCompletion:()

- (nullable id) traverseSubviews: (BOOL)  recursive
withCompletion: (nonnull UgiTraverseSubviewsCompletion)  completion 


Enumerate all subviews

Parameters
recursiveYES to recurse
completionBlock to run for each subview, if the return is not nil, enumeration is aborted and this value is returned
Returns
Value returned by completion or nil

◆ logViewTree:firstArg:()

- (void) logViewTree: (BOOL)  logConstraints
firstArg: (NSString *_Nullable)  firstArg
,   ... 


Log the tree of subviews, for debugging

Parameters
logConstraintsYES log all the constraints
firstArgList of names of parameters to log for each view

◆ logViewParents:firstArg:()

- (void) logViewParents: (BOOL)  logConstraints
firstArg: (NSString *_Nullable)  firstArg
,   ... 


Log the chain of superviews, for debugging

Parameters
logConstraintsYES log all the constraints
firstArgList of names of parameters to log for each view

Enumeration Documentation

◆ UgiShowModalAnimationTypes

- (enum) UgiShowModalAnimationTypes
protected

Type passed to showModal for the type of transition and the placement.

Enumerator
UgiModalCenter 

Show at bottom.

UgiModalCenterWithKeyboard 

Show in center.

Show in center, accounting for a keyboard

UIViewController(UgiUiUtil) Category Reference

Overview

Extension methods for UIViewController.

Instance Methods

(nullable id) - parentViewControllerOfClass:
 
Find the first parent view controller of a specific class More...
 

Instance Method Documentation

◆ parentViewControllerOfClass:()

- (nullable id) parentViewControllerOfClass: (nonnull Class)  viewControllerClass


Find the first parent view controller of a specific class

Parameters
viewControllerClassView controller class to look for
Returns
The view controller