Inherits from UIView
Declared in UZTextView.h
UZTextView.m

Overview

The UZTextView class implements the behavior for a scrollable, multiline, selectable, clickable text region. The class supports the display of text using custom style and link information.

Create subclass of the class and use UZTextView internal category methods if you want to expand the UZTextView class.

Properties

attributedString

The contents of the string to be drawn in this view.

@property (nonatomic, copy) NSAttributedString *attributedString

Declared In

UZTextView.h

contentSize

The bounding size required to draw the string.

@property (nonatomic, readonly) CGSize contentSize

Declared In

UZTextView.h

delegate

Receiver’s delegate. The delegate is sent messages when contents are selected and tapped.

@property (nonatomic, assign) id<UZTextViewDelegate> delegate

Discussion

See UZTextViewDelegate Protocol Reference for the optional methods this delegate may implement.

Declared In

UZTextView.h

highlightRanges

Ranges to be highlighted.

@property (nonatomic, copy) NSArray *highlightRanges

Declared In

UZTextView.h

margin

UIEdgeInsets object, describes a margin around the content. The default value is UIEdgeInsetsZero.

@property (nonatomic, assign) UIEdgeInsets margin

Declared In

UZTextView.h

minimumPressDuration

The duration (in seconds) of a wait before text selection will start. The unit of duration is secondes. The default value is 0.5.

@property (nonatomic, assign) CFTimeInterval minimumPressDuration

Declared In

UZTextView.h

selectedRange

The current selection range of the receiver.

@property (nonatomic, assign) NSRange selectedRange

Declared In

UZTextView.h

Class Methods

sizeForAttributedString:withBoundWidth:

Returns the bounding size required to draw the string.

+ (CGSize)sizeForAttributedString:(NSAttributedString *)attributedString withBoundWidth:(float)width

Parameters

attributedString

Contents of the string to be drawn.

width

The width constraint to apply when computing the string’s bounding rectangle.

Return Value

A rectangle whose size component indicates the width and height required to draw the entire contents of the string.

Declared In

UZTextView.h

sizeForAttributedString:withBoundWidth:margin:

To be written

+ (CGSize)sizeForAttributedString:(NSAttributedString *)attributedString withBoundWidth:(float)width margin:(UIEdgeInsets)margin

Parameters

attributedString

To be written

width

To be written

margin

To be written

Return Value

To be written

Declared In

UZTextView.h

Instance Methods

cancelSelectedText

Deselects selected text of the receiver.

- (BOOL)cancelSelectedText

Return Value

YES if the receiver’s text is selected or NO if it’s not.

Discussion

Warning: This is an internal/private method. Use this method in subclass of UZTextView.

Declared In

UZTextView.h

circumscribingRectForStringFromIndex:toIndex:

Returns the frame rectangle circumscribing the specified string.

- (CGRect)circumscribingRectForStringFromIndex:(int)fromIndex toIndex:(int)toIndex

Parameters

fromIndex

A beginning index to specify strings. The value must lie within the bounds of the receiver.

toIndex

A ending index to specify strings. The value must lie within the bounds of the receiver.

Return Value

CGRect object circumscribing the specified strings.

Discussion

Warning: This is an internal/private method. Use this method in subclass of UZTextView.

Declared In

UZTextView.h

didChangeLongPressGesture:

Callback method for the UILongPressGestureRecognizer object.

- (void)didChangeLongPressGesture:(UILongPressGestureRecognizer *)gestureRecognizer

Parameters

gestureRecognizer

The UILongPressGestureRecognizer object tells this method.

Discussion

Warning: This is an internal/private method. Use this method in subclass of UZTextView.

Declared In

UZTextView.h

drawContent

Draw all contents.

- (void)drawContent

Discussion

Warning: This is an internal/private method. Use this method in subclass of UZTextView.

Declared In

UZTextView.h

drawSelectedLinkFragments

Draw the frame rectangle with tintColor containing the tapped link element of string. Draw nothing when user do not tap any links.

- (void)drawSelectedLinkFragments

Discussion

Warning: This is an internal/private method. Use this method in subclass of UZTextView.

Declared In

UZTextView.h

drawSelectedTextFragmentRectsFromIndex:toIndex:color:

Draw the frame rectangles with specified color, containing specified string.

- (void)drawSelectedTextFragmentRectsFromIndex:(int)fromIndex toIndex:(int)toIndex color:(UIColor *)color

Parameters

fromIndex

A beginning index to specify strings. The value must lie within the bounds of the receiver.

toIndex

A ending index to specify strings. The value must lie within the bounds of the receiver.

color

UIColor object to fill rectangles.

Discussion

Warning: This is an internal/private method. Use this method in subclass of UZTextView.

Declared In

UZTextView.h

drawStringRectForDebug

Draw the background rectangles of strings for debugging.

- (void)drawStringRectForDebug

Discussion

Warning: This is an internal/private method. Use this method in subclass of UZTextView.

Declared In

UZTextView.h

fragmentRectForCursorAtIndex:side:

Returns the frame rectangle, which describes the cursor location and size.

- (CGRect)fragmentRectForCursorAtIndex:(int)index side:(UZTextViewGlyphEdgeType)side

Parameters

index

Index value to show the cursor.

side

The left of right position to show the cursor. See UZTextViewGlyphEdgeType.

Return Value

The frame rectangle of the cursor.

Discussion

Warning: This is an internal/private method. Use this method in subclass of UZTextView.

Declared In

UZTextView.h

fragmentRectsForGlyphFromIndex:toIndex:

Returns the array whose frame rectangles describes regions of strings by specified character indices.

- (NSArray *)fragmentRectsForGlyphFromIndex:(int)fromIndex toIndex:(int)toIndex

Parameters

fromIndex

A beginning index to specify strings. The value must lie within the bounds of the receiver.

toIndex

A ending index to specify strings. The value must lie within the bounds of the receiver.

Return Value

An NSArray object containing frame rectangles.

Discussion

Warning: This is an internal/private method. Use this method in subclass of UZTextView.

Declared In

UZTextView.h

indexForPoint:

Returns CFIndex object which describes the index of the character locating at the point user tapped.

- (CFIndex)indexForPoint:(CGPoint)point

Parameters

point

point The CGPoint object indicates the location user tapped.

Return Value

CFIndex object describes the index of the tapped character.

Discussion

Warning: This is an internal/private method. Use this method in subclass of UZTextView.

Declared In

UZTextView.h

prepareForInitialization

Initialize all properties. This method is called in init methods.

- (void)prepareForInitialization

Discussion

Warning: This is an internal/private method. Use this method in subclass of UZTextView.

Declared In

UZTextView.h

prepareForReuse

Prepares for reusing an object. You have to call this method before you set another attributed string to the object.

- (void)prepareForReuse

Declared In

UZTextView.h

rangeOfLinkStringAtPoint:

Returns the index range of the link element which locates at the point user tapped.

- (NSRange)rangeOfLinkStringAtPoint:(CGPoint)point

Parameters

point

The CGPoint object indicates the location user tapped.

Return Value

Returns index range of the link element.

Discussion

Warning: This is an internal/private method. Use this method in subclass of UZTextView.

Declared In

UZTextView.h

setCursorHidden:

Hides/shows the cursors on UZTextView.

- (void)setCursorHidden:(BOOL)hidden

Parameters

hidden

Specify YES to hide the cursors or NO to show it.

Discussion

Warning: This is an internal/private method. Use this method in subclass of UZTextView.

Declared In

UZTextView.h

setSelectionWithPoint:

Extracts and selects a word which locates at the point user tapped, using CFStringTokenizer.

- (void)setSelectionWithPoint:(CGPoint)point

Parameters

point

The CGPoint object indicates the location user tapped.

Discussion

Warning: This is an internal/private method. Use this method in subclass of UZTextView.

Declared In

UZTextView.h

showUIMenu

Shows UIMenuController on the receiver.

- (void)showUIMenu

Discussion

You have to override canBecomeFirstResponder or this method if you want to make it hide or edit its items forcely.

Warning: This is an internal/private method. Use this method in subclass of UZTextView.

Declared In

UZTextView.h

updateLayout

Updates layout of UZTextView. CTFrameSetter, CTFrame is created, and the content size is calculated. You have to this method after updating attributedString.

- (void)updateLayout

Discussion

Warning: This is an internal/private method. Use this method in subclass of UZTextView.

Declared In

UZTextView.h