Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements on Method comments. #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 44 additions & 34 deletions GSFancyText/src/GSFancyTextView.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,90 +7,100 @@
//

#import <UIKit/UIKit.h>

#import "GSFancyTextDefines.h"
#import "GSFancyText.h"

/// The view class based on GSFancyText model.

/// Features include: setting accessibility lable, auto-resizing, updating view frame height based on content height, etc
/// The view class based on the GSFancyText model.
///
/// Features include setting the accessibility label, auto-resizing, updating view frame height based on content height, etc.

@interface GSFancyTextView : UIView {
GSFancyText* fancyText_;
GSFancyText *fancyText_;
CGFloat contentHeight_;

BOOL matchFrameHeightToContent_;
BOOL matchFrameWidthToContent_;

dispatch_queue_t workingQueue_;

CGSize lastHandledSize_;
}

/// @name Properties

/// The GSFancyText object for this view
@property (nonatomic, retain) GSFancyText* fancyText;
/// The GSFancyText object for this view.
@property (nonatomic, retain) GSFancyText *fancyText;

/// The content height of the fancyText object.
@property (nonatomic, assign, readonly) CGFloat contentHeight;

/** If matchFrameHeightToContent is set to YES, the view frame height will be set to match the content height
* every time updateDisplay method is called.
/** Determines whether the view frame height should match the content height.
*
* If set to YES, the view frame height will be set to match the content height
* every time the updateDisplay method is called.
*
* If it's set to NO, every time we call updateDisplay, only the new width will be used to affect the line height.
* If set to NO, the new width will be used to affect the line height when updateDisplay is called.
*/
@property (nonatomic, assign) BOOL matchFrameHeightToContent;


/** If it is set to YES, the view frame width will be set to match the content width (if the actually content is narrower than assigned width)
* every time updateDisplay method is called.
/** Determines whether the view frame width should match the content width.
*
* If set to YES, the view frame width will be set to match the content width (if the actual content is narrower than the assigned width)
* every time the updateDisplay method is called.
*/
@property (nonatomic, assign) BOOL matchFrameWidthToContent;

/// @name Initialization

/** Initialize a fancy text view with a frame and a fancyText
/** Initializes a fancy text view with a frame and a fancyText object.
*
* @param frame The frame for the view.
* @param fancyText The GSFancyText object to display.
* @return An initialized GSFancyTextView object.
*/
- (id)initWithFrame:(CGRect)frame fancyText:(GSFancyText*)fancyText;
- (id)initWithFrame:(CGRect)frame fancyText:(GSFancyText *)fancyText;

/** The easiest way to create a simple fancy text view.
/** Creates a simple fancy text view.
*
* e.g. [GSFancyTextView fancyTextViewWithFrame:CGRectMake(0, 0, 200, 200) markupText:@"<strong>Hello</strong> %@ %d", @"World", 2013];
* @param frame The frame for the view.
* @param markupText The markup text to display.
* @return A new GSFancyTextView object.
*
* e.g., [GSFancyTextView fancyTextViewWithFrame:CGRectMake(0, 0, 200, 200) markupText:@"<strong>Hello</strong> %@ %d", @"World", 2013];
*/
+ (GSFancyTextView*)fancyTextViewWithFrame:(CGRect)frame markupText:(NSString*)markup,...;

+ (GSFancyTextView *)fancyTextViewWithFrame:(CGRect)frame markupText:(NSString *)markup,...;

/// @name Frame update

/** Call this method when fancy text is set or changed.
/** Updates the display when the fancy text is set or changed.
*
* It will do 3 things: 1. re-generate the lines, 2. update the view height is demanded, 3. setNeedsDisplay for the view
* This method performs the following:
* 1. Re-generates the lines.
* 2. Updates the view height if required.
* 3. Calls setNeedsDisplay for the view.
*
* For best visual experience, call this method in view controller's willAnimateRotationToInterfaceOrientation:duration: method
* For the best visual experience, call this method in the view controller's willAnimateRotationToInterfaceOrientation:duration: method.
*/
- (void)updateDisplay;


- (void)updateDisplayWithCompletionHandler:(void(^)())completionHandler;

/** Updates the frame size based on fancyText content height
/** Updates the display with a completion handler.
*
* We may assign extra/more than enough space at the beginning, so after the drawing we can truncate the view frame to fit the content.
* @param completionHandler The block to execute after the display update.
*/
- (void)updateDisplayWithCompletionHandler:(void (^)(void))completionHandler;

/** Updates the frame size based on the fancyText content height.
*
* Note: this method sets frame height for once. For automatical frame height update, see matchFrameHeightToContent property.
* This method sets the frame height once. For automatic frame height updates, see matchFrameHeightToContent property.
*/
- (void)setFrameHeightToContentHeight;

/** Updates the frame size based on fancyText content width
/** Updates the frame size based on the fancyText content width.
*
* Does it once. For automatical frame width update, see matchFrameWidthToContent property.
* This method sets the frame width once. For automatic frame width updates, see matchFrameWidthToContent property.
*/
- (void)setFrameWidthToContentWidth;

/// @name Accessibility label

/** Enable and update the accessibility label
/** Enables and updates the accessibility label.
*/
- (void)updateAccessibilityLabel;

Expand Down