Advertisement
Guest User

Untitled

a guest
Apr 16th, 2014
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. #import <UIKit/UIKit.h>
  2.  
  3. @interface CustomTextView : UITextView <NSLayoutManagerDelegate>
  4.  
  5. @end
  6.  
  7. #import "CustomTextView.h"
  8.  
  9. @implementation CustomTextView
  10.  
  11. - (id)initWithFrame:(CGRect)frame
  12. {
  13. self = [super initWithFrame:frame];
  14. if (self)
  15. {
  16. self.backgroundColor = [UIColor clearColor];
  17. self.font = [UIFont systemFontOfSize:21.0];
  18. self.dataDetectorTypes = UIDataDetectorTypeAll;
  19. self.layoutManager.delegate = self;
  20. self.tintColor = [UIColor companyBlue];
  21. [self setLinkTextAttributes:@{NSForegroundColorAttributeName:[UIColor companyBlue]}];
  22. self.contentInset = UIEdgeInsetsMake(0.5, 0, 0, 0);
  23. self.scrollEnabled = NO;
  24. self.textContainer.maximumNumberOfLines = 9;
  25. self.textContainer.lineBreakMode = NSLineBreakByCharWrapping;
  26. }
  27. return self;
  28. }
  29.  
  30. - (CGFloat)layoutManager:(NSLayoutManager *)layoutManager lineSpacingAfterGlyphAtIndex:(NSUInteger)glyphIndex withProposedLineFragmentRect:(CGRect)rect
  31. {
  32. return 4.9;
  33. }
  34.  
  35. @end
  36.  
  37. - (id)initWithFrame:(CGRect)frame
  38. {
  39. self = [super initWithFrame:frame];
  40. if (self)
  41. {
  42. self.backgroundColor = [UIColor clearColor];
  43. self.font = [UIFont systemFontOfSize:21.0];
  44. self.dataDetectorTypes = UIDataDetectorTypeAll;
  45. self.layoutManager.delegate = self;
  46. self.tintColor = [UIColor companyBlue];
  47. [self setLinkTextAttributes:@{NSForegroundColorAttributeName:[UIColor companyBlue]}];
  48. self.scrollEnabled = NO;
  49. self.textContainerInset = UIEdgeInsetsMake(8.5, 0, 0, 0);
  50. self.textContainer.maximumNumberOfLines = 9;
  51. self.textContainer.lineBreakMode = NSLineBreakByTruncatingTail;
  52. }
  53. return self;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement