Skip to content
This repository
file 128 lines (97 sloc) 3.99 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
//
// DTAttributedTextView.h
// DTCoreText
//
// Created by Oliver Drobnik on 1/12/11.
// Copyright 2011 Drobnik.com. All rights reserved.
//

#import "DTAttributedTextContentView.h"

@class DTAttributedTextView;

/**
This view is designed to be a replacement for `UITextView`. It is a `UIScrollView` subclass and creates a <DTAttributedTextContentView> as content view for displaying the text.
The content view of type <DTAttributedTextContentView> is created lazily. You should not set values on it directly if you use it in conjunction with this class for scrolling.
*/

@interface DTAttributedTextView : UIScrollView
{
// ivars needed by subclasses
DTAttributedTextContentView *_attributedTextContentView;
}

/**
@name Providing Content
*/

/**
The attributed text to be displayed in the text content view of the receiver.
*/
@property (nonatomic, strong) NSAttributedString *attributedString;


/**
A delegate implementing DTAttributedTextContentViewDelegate to provide custom subviews for images and links.
*/
@property (nonatomic, DT_WEAK_PROPERTY) IBOutlet id <DTAttributedTextContentViewDelegate> textDelegate;


/**
Performs a new layout pass on the receiver. This destroys the frame setter, calls relayoutText on the content view and marks the receiver as needing layout so that custom subviews get appropriately sized.
*/
- (void)relayoutText;

/**
@name Accessing Subviews
*/

/**
References to the DTAttributedTextContentView that display the text. This is not named contentView because this class inherits from `UIScrollView` which has an internal property of this name
*/
@property (nonatomic, strong, readonly) DTAttributedTextContentView *attributedTextContentView;

/**
A view to be displayed behind the text content view
*/
@property (nonatomic, strong) IBOutlet UIView *backgroundView;


/**
@name Customizing Display
*/

/**
If the content view of the receiver should draw links. Set to `NO` if displaying links as custom views via textDelegate;
Defaults to `YES` if you supply your own link drawing then set this property to NO and supply your custom view (e.g. <DTLinkButton>) via the <textDelegate>.
*/
@property (nonatomic, assign) BOOL shouldDrawLinks;

/**
If the content view of the receiver should draw images. Set to `NO` if displaying images as custom views via textDelegate;
Defaults to `YES` if you supply your own image drawing then set this property to NO and supply your custom image view (e.g. <DTLazyImageView>) via the <textDelegate>.
*/
@property (nonatomic, assign) BOOL shouldDrawImages;


/**
@name Customizing Content View
*/

/**
You can override this method to provide a different class to use for the content view. If you replace the content view class then it should inherit from <DTAttributedTextContentView> which is also the default.
@returns The class to use for the content view.
*/
- (Class)classForContentView;

/**
@name User Interaction
*/

/**
Scrolls the receiver to the anchor with the given name to the top.
@param anchorName The name of the href anchor.
@param animated `YES` if the movement should be animated.
*/
- (void)scrollToAnchorNamed:(NSString *)anchorName animated:(BOOL)animated;

/**
Scrolls the receiver until the text in the specified range is visible.
@param range The range of text to scroll into view.
@param animated `YES` if the movement should be animated.
*/
- (void)scrollRangeToVisible:(NSRange)range animated:(BOOL)animated;

/**
@name Working with a Cursor
*/

/**
Determines the closest string index to a point in the receiver's frame.
This can be used to find the cursor position to position an input caret at.
@param point The point
@returns The resulting string index
*/
- (NSInteger)closestCursorIndexToPoint:(CGPoint)point;

/**
The rectangle to draw a caret for a given index
@param index The string index for which to determine a cursor frame
@returns The cursor rectangle
*/
- (CGRect)cursorRectAtIndex:(NSInteger)index;

@end
Something went wrong with that request. Please try again.