1、IQKeyboardManager 禁止某个 UITextField 的工具栏
针对 ViewController 级别禁用工具栏:IQKeyboardManager.sharedManager().disableToolbarInViewControllerClass ,如果这个 UITextField 直接 add 到 window 上的这个方法就不管用了,可以直接设置 inputAccessoryView = UIView() 即可
2、AFNetworking 3.0 输出 Log
let networkLogger = AFNetworkActivityLogger.sharedLogger()
networkLogger.startLogging()
let console = AFNetworkActivityConsoleLogger()
console.level = AFHTTPRequestLoggerLevel.AFLoggerLevelDebug
networkLogger.addLogger(console)
3、计算返回label有几行文字
extension UILabel {
func lineCount() -> Int {
if let text = self.text {
let size = NSString(string: text).boundingRectWithSize(CGSizeMake(bounds.width, CGFloat.max), options: NSStringDrawingOptions.UsesLineFragmentOrigin, attributes: [NSFontAttributeName : self.font], context: nil)
return Int(ceil(size.height / self.font.lineHeight))
}
return 0
}
}
4、打开qq,
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mqq://im/chat?chat_type=wpa&uin=501542587&version=1&src_type=web"]];
5、在程序内使iPhone关机
首先在程序中引用
#include <sys/reboot.h>
然后使用
reboot(RB_HALT);
就可以直接将 iPhone 关机
6、uitextfiled 添加监听事件
let tf = UITextField(frame: CGRect(x: 10, y: 100, width: 100, height: 80));
tf.placeholder = "23123123"
self.view.addSubview(tf);
tf.addTarget(self, action: #selector(valuechange), for: .editingChanged);
7、获取app信息
NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
// app名称
NSString *app_Name = [infoDictionary objectForKey:@"CFBundleDisplayName"];
// app版本
NSString *app_Version = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
// app build版本
NSString *app_build = [infoDictionary objectForKey:@"CFBundleVersion"];
8、常见上架等信息查询
http://help.apple.com/itunes-connect/developer/#/devd274dd925
9、iOS11.4 直接设置UIImageView的layer不会触发离屏渲染
let img = UIImageView();
img.layer.masksToBounds = true;
img.layer.cornerRadius = FIT_WIDTH(150);
/// 设置背景色 会触发离屏渲染
img.backgroundColor = UIColor.red
return img;