-
Notifications
You must be signed in to change notification settings - Fork 344
How to use
There are two possible methods to include these classes in your project:
-
Using Cocoapods:
- add
pod "OHAttributedLabel"
to your Podfile
- add
-
Manually:
- Include the
OHAttributedLabel.xcodeproj
project in your Xcode4 workspace - Add the
libOHAttributedLabel.a
library and theCoreText.framework
to your "Link binary with libraries" Build Phase. - Add the relative path to the OHAttributedLabel source in your "User Header Search Path" Build Setting
- Add the
-ObjC
flag in the "Other Linker Flags" Build Setting if not present already
- Include the
Then in your application code, when you want to make use of OHAttributedLabel methods, import the headers as usual: #import "OHAttributedLabel.h"
or #import "NSAttributedString+Attributes.h"
etc.
-
If the compiler can't find the headers to import, be sure that you added quotes around the relative paths you added in your "User Header Search Path" build settings.
-
If you use an Xcode version prior to 4.2 (and LLVM version prior to 3.0), you will need to add the
-all_load
flag in addition to the-ObjC
flag, for the category to be loaded from the library. This is due to a bug in LLVM which has been fixed in LLVM 3.0 / Xcode 4.2 since. In that case, updating your Xcode version is strongly recommended. -
If your workspace can't detect implicit dependencies between your application project and the
OHAttributedLabel
project, and thus does not build theOHAttributedLabel
project automatically before your application and generate link errors:- Make sure that the
libOHAttributedLabel.a
present in your application's project (in the Project Navigator on the left) is referenced as "Relative to Build Products" and not "Relative to Group" or "Relative to Project" (see the File Inspector on the right) - Make sure that the relative path of this
libOHAttributedLabel.a
is only "libOHAttributedLabel.a" (as it is relative to your Build Products directoryà and not some fancy relative path with a lot of"../../.."
. If you have some fancy path (known Xcode bug sadly still not fixed by Apple), you will need to edit yourproject.pbxproj
file (inside your.xcodeproj
bundle) to fix this ugly path.
- Make sure that the
There is no explicit docset or documentation of the class yet sorry (never had time to write one), but
- The method names should be self-explanatory (hopefully) as I respect the standard ObjC naming conventions.
- There are doxygen/javadoc-like documentation in the headers that should also help you describe the methods
- The provided example should also demonstrate quite every typical usages — including justifying the text, dynamically changing the style/attributes of a range of text, adding custom links, make special links with a custom behavior (like catching @mention and #hashtags), and customizing the appearance/color of links.