DogeKit 受到 这个项目 启发。请按您的喜好使用。
如果您使用 Cocoapods: pod 'DogeKit'
然后包含 "DogeKit.h"
如果不使用,只需将 DogeKit.h 和 DogeKit.m 复制到您的项目中,并在您想使用它的任何地方包含它。
#include "DogeKit.h"
DogeKit *dk = [[DogeKit alloc] initWithTargetView:self.view]; //Init with a target view
[dk start]; //Start adding comments to your view
[dk stop]; //Stop adding comments to your view
或者您可以使用 sharedInstance
。这样,如果您想在整个应用程序中支持 DogeKit,您可以这样做。
例如,您可以设置在任何视图都按导航栏(或什么的)时触发 DogeKit
在 AppDelegate 或其他地方
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
UINavigationController *navigationController = (UINavigationController *)self.window.rootViewController;
// Add gesture recognizer to toggle DogeKit if two figer tap
// is done on navigation bar
UITapGestureRecognizer *superTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(toggleDogeKit)];
superTap.numberOfTapsRequired = 1;
superTap.numberOfTouchesRequired = 2;
[navigationController.navigationBar addGestureRecognizer:superTap];
return YES;
}
// More AppDelegate Code...
- (void)toggleDogeKit {
[[DogeKit sharedInstance] toggle];
}
您也可以设置自己的“事物”。然后打印出带有前缀的内容。前缀存储在一个可变的数组中,因此您可以按需更改它们。您可以考虑为用户当前上下文中的所有文本更改前缀。这么多新闻。这么多股票。哇。
dk.things = [NSMutableArray arrayWithObjects:<(id), ...>, nil];
实现 DogeKitDelgate 后,“事物”将更为强大。
// After initilization
dk.delegate = self;
[dk createThings]; //Will traverse your hierarchy and pull out words and feed them to your delegate method.
#pragma mark -
#pragma mark DogeKitDelegate methods
-(BOOL)allowWordInThings:(NSString *)word{
if (word.length > 4) { //A very simple filter
return YES;
} else return NO;
}
如果您真的想,也可以通过这次拉取请求this pull request再次清除标签。
[dk clear];
您可以通过 minSize
、 maxSize
和 shouldRotateLabels
属性来控制标签的旋转和大小,这些都归功于这些拉取请求。
我非常乐意!
让我们听听它们!(请说好的!)
如果你感兴趣,我是 @samjarman
只需提交一个编辑此 ReadMe 的拉取请求。或者向我发送推文。
谁会是第一个?