1:调用系统声音(拍照声音)
a:在 工程下的target - Build Phases –Link Binary With Libraries –添加AudioToolbox.framework
b:在头文件中引入系统库 import<AudioToolbox/AudioToolbox.h>
c:函数中调用,更多声音 参考这里
AudioServicesPlaySystemSound(1108);
2:获取用户复制的内容(像淘宝一样)
NSString *string = [UIPasteboard generalPasteboard].string;
3:统一收起键盘
[[[UIApplication sharedApplication] keyWindow] endEditing:YES];
4:获取某个字体的高度
font.lineHeight;
5:移除所有子视图
[[someView subviews]makeObjectsPerformSelector:@selector(removeFromSuperview)];
6: 让label在指定位置换行
label.numberOfLines = 0;
label.text = @"此处\n换行";
7:摇一摇功能
a、打开摇一摇功能
[UIApplication sharedApplication].applicationSupportsShakeToEdit = YES;
b:让需要摇动的控制器成为第一响应者
[self becomeFirstResponder];
c、实现以下方法
// 开始摇动 - (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event
// 取消摇动 - (void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event
// 摇动结束 - (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
8:在状态栏增加网络请求的菊花,类似safari加载网页的时候状态栏菊花
sharedApplication].networkActivityIndicatorVisible = YES;
9:长按复制
- (void)viewDidLoad{
[self.view addGestureRecognizer:[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(pasteBoard:)]];
}
- (void)pasteBoard:(UILongPressGestureRecognizer *)longPress {
if(longPress.state == UIGestureRecognizerStateBegan) {
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
pasteboard.string = @"需要复制的文本"; }
}
10:设置textfield左边的间距,不通过自定义的方式
CGRect frame = textInputTitle.frame;
frame.size.width = 10;// 距离左侧的距离
UIView *leftview = [[UIView alloc] initWithFrame:frame];
textInputTitle.leftViewMode = UITextFieldViewModeAlways;
textInputTitle.leftView = leftview;
上面是想要自己保存的一些东西,其他功能请参考这里
网友评论