i have got an issue, i can't change frame.size.width in 3rd party lib. Could not find any normal solution to change the width, so i decided to execute objc/runtime.
I've got ViewController and its property DTAttributedTextView *v.
@interface DTAttributedTextView : UIScrollView
{
// ivars needed by subclasses
DTAttributedTextContentView *_attributedTextContentView;
}
@property (nonatomic, strong) NSAttributedString *attributedString;
@property (nonatomic, DT_WEAK_PROPERTY) IBOutlet
id<DTAttributedTextContentViewDelegate> textDelegate;
@property (nonatomic, strong) IBOutlet UIView *backgroundView;
....
@end
v got @property ( .., readonly) DTAttributedTextContentView *attributedTextContentView
@interface DTAttributedTextContentView : UIView
{
NSAttributedString *_attributedString;
DTCoreTextLayoutFrame *_layoutFrame;
UIEdgeInsets _edgeInsets;
NSMutableDictionary *customViewsForAttachmentsIndex;
BOOL _flexibleHeight;
// for layoutFrame
NSInteger _numberOfLines;
NSLineBreakMode _lineBreakMode;
NSAttributedString *_truncationString;
}
attributedTextContentView got @property DTCoreTextLayoutFrame *layoutFrame
@interface DTCoreTextLayoutFrame : NSObject
{
CGRect _frame;
NSArray *_lines;
NSArray *_paragraphRanges;
NSArray *_textAttachments;
NSAttributedString *_attributedStringFragment;
}
So basically i need to change
self.v.attributedTextContentView.layoutFrame.frame.size.width
for a pitty i cant use
objc_setAssociatedObject(self.v.attributedTextContentView.layoutFrame,@"frame.size.width",@200,OBJC_ASSOCIATION_ASSIGN);
nor
objc_setAssociatedObject(self.v.attributedTextContentView.layoutFrame,@"frame",CGRectMake(0,0,200,1000),OBJC_ASSOCIATION_ASSIGN);
because i can't access ivars by dot notation, nor send CGStruct as CGFloat required event if &.
As another solution to this situation i see creating object by object using runtime and then change the pointer. Maybe some steps could be done using copy. My problem is that im total newbie in objc/runtime and also documentation is really poor. Im struggling to learn this significant technology so i'm intentionally do not solve the exact problem using other options.
Any help would be highly appreciated. Thanx in advance.