Skip to content

Commit

Permalink
Added solution of auto layout to get the intrinsic content size of th…
Browse files Browse the repository at this point in the history
…e label view.
  • Loading branch information
devedbox committed May 18, 2016
1 parent f008dbe commit 5eade43
Show file tree
Hide file tree
Showing 8 changed files with 386 additions and 79 deletions.
4 changes: 2 additions & 2 deletions AXAttributedLabel.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Pod::Spec.new do |s|

s.name = "AXAttributedLabel"
s.version = "0.2.1"
s.version = "0.2.2"
s.summary = "`AXAttributedLabel` is an iOS customizable attributed label that displays attributed text."

s.description = <<-DESC
Expand All @@ -21,7 +21,7 @@ s.platform = :ios, "7.0"
# s.ios.deployment_target = “7.0”
# s.osx.deployment_target = "10.7"
# s.watchos.deployment_target = "2.0"
s.source = { :git => "https://github.com/devedbox/AXAttributedLabel.git", :tag => "0.2.1" }
s.source = { :git => "https://github.com/devedbox/AXAttributedLabel.git", :tag => "0.2.2" }
s.source_files = "AXAttributedLabel/AXAttributedLabel/*.{h,m}"
#s.exclude_files = "Classes/Exclude"
# s.public_header_files = "Classes/**/*.h"
Expand Down
6 changes: 6 additions & 0 deletions AXAttributedLabel.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
015043B81CEAF11300164ABD /* ViewController2.m in Sources */ = {isa = PBXBuildFile; fileRef = 015043B71CEAF11300164ABD /* ViewController2.m */; };
0189A1A61CDC465100D0F0D8 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 0189A1A51CDC465100D0F0D8 /* main.m */; };
0189A1A91CDC465100D0F0D8 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 0189A1A81CDC465100D0F0D8 /* AppDelegate.m */; };
0189A1AC1CDC465100D0F0D8 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 0189A1AB1CDC465100D0F0D8 /* ViewController.m */; };
Expand Down Expand Up @@ -38,6 +39,8 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
015043B61CEAF11300164ABD /* ViewController2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewController2.h; sourceTree = "<group>"; };
015043B71CEAF11300164ABD /* ViewController2.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ViewController2.m; sourceTree = "<group>"; };
0189A1A11CDC465100D0F0D8 /* AXAttributedLabel.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AXAttributedLabel.app; sourceTree = BUILT_PRODUCTS_DIR; };
0189A1A51CDC465100D0F0D8 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
0189A1A71CDC465100D0F0D8 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -117,6 +120,8 @@
0189A1A81CDC465100D0F0D8 /* AppDelegate.m */,
0189A1AA1CDC465100D0F0D8 /* ViewController.h */,
0189A1AB1CDC465100D0F0D8 /* ViewController.m */,
015043B61CEAF11300164ABD /* ViewController2.h */,
015043B71CEAF11300164ABD /* ViewController2.m */,
0189A1DA1CDC662400D0F0D8 /* AXAttributedLabel */,
0189A1AD1CDC465100D0F0D8 /* Main.storyboard */,
0189A1B01CDC465100D0F0D8 /* Assets.xcassets */,
Expand Down Expand Up @@ -364,6 +369,7 @@
files = (
0189A1AC1CDC465100D0F0D8 /* ViewController.m in Sources */,
0189A1A91CDC465100D0F0D8 /* AppDelegate.m in Sources */,
015043B81CEAF11300164ABD /* ViewController2.m in Sources */,
0189A1A61CDC465100D0F0D8 /* main.m in Sources */,
0189A1D91CDC662000D0F0D8 /* AXAttributedLabel.m in Sources */,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.ExceptionBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
scope = "0"
Expand Down
38 changes: 30 additions & 8 deletions AXAttributedLabel/AXAttributedLabel/AXAttributedLabel.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ typedef NS_OPTIONS(uint64_t, AXAttributedLabelDetectorType) { // a single typ
AXAttributedLabelDetectorTypeTransitInformation = NSTextCheckingTypeTransitInformation,
AXAttributedLabelDetectorTypeImage = 1ULL << 21
/* No implementation.
AXAttributedLabelDetectorTypeOrthography = NSTextCheckingTypeOrthography,
AXAttributedLabelDetectorTypeSpelling = NSTextCheckingTypeSpelling,
AXAttributedLabelDetectorTypeGrammar = NSTextCheckingTypeGrammar,
AXAttributedLabelDetectorTypeQuote = NSTextCheckingTypeQuote,
AXAttributedLabelDetectorTypeDash = NSTextCheckingTypeDash,
AXAttributedLabelDetectorTypeReplacement = NSTextCheckingTypeReplacement,
AXAttributedLabelDetectorTypeCorrection = NSTextCheckingTypeCorrection,
AXAttributedLabelDetectorTypeRegularExpression = NSTextCheckingTypeRegularExpression,
AXAttributedLabelDetectorTypeOrthography = NSTextCheckingTypeOrthography,
AXAttributedLabelDetectorTypeSpelling = NSTextCheckingTypeSpelling,
AXAttributedLabelDetectorTypeGrammar = NSTextCheckingTypeGrammar,
AXAttributedLabelDetectorTypeQuote = NSTextCheckingTypeQuote,
AXAttributedLabelDetectorTypeDash = NSTextCheckingTypeDash,
AXAttributedLabelDetectorTypeReplacement = NSTextCheckingTypeReplacement,
AXAttributedLabelDetectorTypeCorrection = NSTextCheckingTypeCorrection,
AXAttributedLabelDetectorTypeRegularExpression = NSTextCheckingTypeRegularExpression,
*/
};

Expand Down Expand Up @@ -67,6 +67,10 @@ NS_CLASS_AVAILABLE(10_0, 7_0) @interface AXAttributedLabel : UITextView
/// Number of lines. Defaults is 0 means no limits.
@property(assign, NS_NONATOMIC_IOSONLY) NSUInteger numberOfLines;

// Support for constraint-based layout (auto layout)
// If nonzero, this is used when determining -intrinsicContentSize for multiline labels
@property(nonatomic) IBInspectable CGFloat preferredMaxLayoutWidth;

// Default value : empty array An array of UIBezierPath representing the exclusion paths inside the receiver's bounding rect.
@property(copy, NS_NONATOMIC_IOSONLY) NSArray<UIBezierPath *> *exclusionPaths;
@property(copy, NS_NONATOMIC_IOSONLY) NSArray<UIView *> *exclusionViews;
Expand All @@ -88,6 +92,7 @@ NS_CLASS_AVAILABLE(10_0, 7_0) @interface AXAttributedLabel : UITextView

+ (instancetype)attributedLabel;
- (CGRect)boundingRectForTextRange:(NSRange)range;
+ (CGSize)boundingSizeForLabelWithText:(NSString *)text font:(UIFont *_Nonnull)font exclusionPaths:(NSArray<UIBezierPath *> *_Nullable)exclusionPaths perferredMaxLayoutWidth:(CGFloat)preferredMaxLayoutWidth;

- (void)setMenuItems:(NSArray<AXMenuItem *>*)menuItems UI_APPEARANCE_SELECTOR;
- (void)addMenuItem:(AXMenuItem *)item,...;
Expand Down Expand Up @@ -199,6 +204,23 @@ typedef void(^AXMenuItemBlock)(AXAttributedLabel *_Nonnull label, AXMenuItem *_N
+ (instancetype)itemWithTitle:(NSString *)title handler:(AXMenuItemBlock)handler;
@end

@interface AXAttributedStringOptions : NSObject
/// Attributes.
@property(strong, nonatomic, nullable) NSDictionary<NSString*, id> *attributes;
/// Image detector pattern.
@property(copy, nonatomic, nullable) NSString *imageDetectorPattern;
/// Should interact with URLs.
@property(assign, nonatomic) BOOL shouldInteractWithURLs;
/// Detector types.
@property(assign, nonatomic) AXAttributedLabelDetectorTypes detectorTypes;
/// Other links.
@property(copy, nonatomic, nullable) NSArray<NSTextCheckingResult *> *results;
/// Font.
@property(strong, nonatomic) UIFont *font;
/// Attributed label.
@property(weak, nonatomic, nullable) AXAttributedLabel *attributedLabel;
@end

@interface AXAttributedLabel (Unavailable)
#pragma mark - Unavailable Methods
- (void)scrollRangeToVisible:(NSRange)range __attribute__((unavailable("AXAttributedLabel cannot scroll range to visible rect for current version")));
Expand Down
Loading

0 comments on commit 5eade43

Please sign in to comment.