01 2016 档案
摘要:1 // 监听键盘 2 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShowAction:) name:UIKeyboardWillShowNotification obj
阅读全文
摘要:需要同时写如下两行代码 self.resendBtn.titleLabel.text = str; [self.resendBtn setTitle:str forState:UIControlStateDisabled];
阅读全文
摘要:在AppDelegate中添加下面一句 self.window.backgroundColor = [UIColor whiteColor];
阅读全文
摘要:#ifdef __OBJC__ #import #import #import "UIView+Extension.h"// 颜色#define HMColor(r, g, b) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/25...
阅读全文
摘要:1 #import 2 3 @interface HMFileDownloader : NSObject 4 /** 5 * 所需要下载文件的远程URL(连接服务器的路径) 6 */ 7 @property (nonatomic, copy) NSString *url; ...
阅读全文
摘要:1 #import "HMViewController.h" 2 3 @interface HMViewController () 4 @property (weak, nonatomic) IBOutlet UIProgressView *progressView; 5 /** 6...
阅读全文
摘要:1 #import "HMViewController.h" 2 3 @interface HMViewController () 4 @property (weak, nonatomic) IBOutlet UIProgressView *progressView; 5 /** 6...
阅读全文
摘要:1 #import "HMViewController.h" 2 #import "MBProgressHUD+MJ.h" 3 4 @interface HMViewController () 5 @property (weak, nonatomic) IBOutlet UITextField ...
阅读全文
摘要:1 #import "HMViewController.h" 2 #import "MBProgressHUD+MJ.h" 3 4 @interface HMViewController () 5 @property (weak, nonatomic) IBOutlet UIText...
阅读全文
摘要:1 #import "HMViewController.h" 2 3 @interface HMViewController () 4 @property (weak, nonatomic) IBOutlet UIImageView *imageView1; 5 @property (...
阅读全文
摘要:1 - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 2 { 3 dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORI...
阅读全文
摘要:1 @implementation HMViewController 2 3 - (void)viewDidLoad 4 { 5 [super viewDidLoad]; 6 7 [self performSelectorInBackground:@sel...
阅读全文
摘要:为了提高应用的用户体验,经常需要邀请用户对应用进行评分应用评分无非就是跳转到AppStore展示自己的应用,然后由用户自己撰写评论如何跳转到AppStore,并且展示自己的应用方法1 NSString *appid = @"444934666"; NSString *str = [NSStrin...
阅读全文
摘要:有时候,需要在本应用中打开其他应用,比如从A应用中跳转到B应用首先,B应用得有自己的URL地址(在Info.plist中配置)B应用的URL地址就是:mj://ios.itcast.cn 接着在A应用中使用UIApplication完成跳转 NSURL *url = [NSURL URLWith...
阅读全文
摘要:如果想打开一些常见文件,比如html、txt、PDF、PPT等,都可以使用UIWebView打开只需要告诉UIWebView文件的URL即可至于打开一个远程的共享资源,比如http协议的,也可以调用系统自带的Safari浏览器:NSURL *url = [NSURL URLWithString:@”...
阅读全文
摘要:1 用自带的邮件客户端,发完邮件后不会自动回到原应用 2 NSURL *url = [NSURL URLWithString:@"mailto://10010@qq.com"]; 3 [[UIApplication sharedApplication] openURL:url]; 1 跟发短信的第2...
阅读全文
摘要:1 直接跳到发短信界面,但是不能指定短信内容,而且不能自动回到原应用 2 NSURL *url = [NSURL URLWithString:@"sms://10010"]; 3 [[UIApplication sharedApplication] openURL:url]; 1 如果想指定短信内容...
阅读全文
摘要:1 最简单最直接的方式:直接跳到拨号界面2 NSURL *url = [NSURL URLWithString:@"tel://10010"];3 [[UIApplication sharedApplication] openURL:url];4 缺点5 电话打完后,不会自动回到原应用,直接停留在通...
阅读全文
摘要:1 #import 2 3 @interface NJProductViewController : UICollectionViewController 4 // 'UICollectionView must be initialized with a non-nil layout...
阅读全文
摘要:#import @interface NJProductViewController : UICollectionViewController// 'UICollectionView must be initialized with a non-nil layout parameter'// 创建U...
阅读全文
摘要:1 #import 2 3 @interface NJProductItem : NSObject 4 /** 5 * 图标 6 */ 7 @property (nonatomic, copy) NSString *icon; 8 /** 9 * 标题10 */11 @proper...
阅读全文
摘要:1 #import 2 3 @interface NJNavigationController : UINavigationController 4 5 @end 6 7 8 9 #import "NJNavigationController.h"10 11 @interface NJ...
阅读全文
摘要:1 #import 2 3 @interface NJTitleButton : UIButton 4 5 @end 6 7 8 #import "NJTitleButton.h" 9 10 @interface NJTitleButton ()11 @property (nonatom...
阅读全文
摘要:1 // 3.设置导航条的主题 2 // 如果要同时设置很多UINavigationBar的样式, 可以通过设置UINavigationBar的主题的方式来设置以便简化代码 3 UINavigationBar *navBar = [UINavigationBar appea...
阅读全文
摘要:1 #import 2 3 @protocol NJTabBarDelegate 4 /** 5 * @param from 从哪个视图(视图索引) 6 * @param to 到哪个视图(视图索引) 7 */ 8 - (void)tabBarDidSelectBtnFrom:...
阅读全文
摘要:1 #import "NJViewController.h" 2 3 @interface NJViewController () 4 @property (weak, nonatomic) IBOutlet UIView *cutomView; 5 6 @end 7 8 @implemen...
阅读全文
摘要:1 // 平移动画 2 CABasicAnimation *a1 = [CABasicAnimation animation]; 3 a1.keyPath = @"transform.translation.y"; 4 a1.toValue = @(100); 5 ...
阅读全文
摘要:1 #import "NJViewController.h" 2 3 @interface NJViewController () 4 @property (weak, nonatomic) IBOutlet UIImageView *iconView; 5 - (IBAction)nextBt...
阅读全文
摘要:1 #import "NJViewController.h" 2 3 #define angle2Radian(angle) ((angle) / 180.0 * M_PI) 4 5 @interface NJViewController () 6 7 @property (weak, no...
阅读全文
摘要:1 #import "NJViewController.h" 2 3 @interface NJViewController () 4 5 @property (weak, nonatomic) IBOutlet UIView *customView; 6 - (IBAction)btnCli...
阅读全文
摘要:Core Animation,中文翻译为核心动画,它是一组非常强大的动画处理api,使用它能做出非常绚丽的动画效果,而且往往事半功倍。也就是说食用少量的代码就能实现非常强大的功能。Core Animation可以用在Mac OS X和IOS平台Core Animation的动画执行过程都是在后台操作...
阅读全文
摘要:两种方式 1 #import 2 3 @interface NJLayer : CALayer 4 @end 5 6 7 #import "NJLayer.h" 8 9 @implementation NJLayer10 11 // 重写该方法, 在该方法中给layer上绘制图形12 //...
阅读全文
摘要:1. 每一个UIView内部都默认关联着一个CALayer,我们可以称这个Layer为Root Layer2. 所有的非Root Layer,也就是手动创建的CALayer对象都存在着隐式动画什么是隐式动画 1 当对非Root Layer的部分属性进行修改时,默认会自动产生一些动画效果 2 而这...
阅读全文
摘要:1 // 如果一个控制是另外一个控件的子控件, 那么这个控件中的layer也是另外一个控件的子layer2 NSLog(@"star - %@", self.view.layer.sublayers);3 CALayer *layer = [CALayer layer];4...
阅读全文
摘要:1 /**/ 2 // 设置layer边框 3 self.customView.layer.borderWidth = 10; 4 // 设置layer边框颜色 5 self.customView.layer.borderColor =[UIColor bl...
阅读全文
摘要:1 self.iconView.layer.borderWidth = 10;2 self.iconView.layer.borderColor = [UIColor purpleColor].CGColor;3 self.iconView.layer.cornerRadius = ...
阅读全文
摘要:1 #import "NJViewController.h" 2 3 @interface NJViewController () 4 @property (weak, nonatomic) IBOutlet UIView *customView; 5 6 @end 7 8 @impleme...
阅读全文
摘要:1 #import "NJViewController.h" 2 3 @interface NJViewController () 4 @property (weak, nonatomic) IBOutlet UIImageView *iconView; 5 6 @end 7 8 @impl...
阅读全文
摘要:1 // 1.创建手势识别器 2 UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] init]; 3 // 1.1设置长按手势识别器的属性 4 // ...
阅读全文
摘要:1 - (void)viewDidLoad 2 { 3 [super viewDidLoad]; 4 5 // 向上 6 UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc] ini...
阅读全文
摘要:一次完整的触摸事件的传递响应的过程UIAppliction --> UIWiondw -->递归找到最适合处理事件的控件控件调用touches方法-->判断是否实现touches方法-->没有实现默认会将事件传递给上一个响应者-->找到上一个响应者1.响应者链条:由很多响应者链接在一起组合起来的一个...
阅读全文
摘要:发生触摸事件后,系统会将该事件加入到一个由UIApplication管理的事件队列中UIApplication会从事件队列中取出最前面的事件并将事件分发下去以便处理,通常先发送给应用程序的主窗口(keyWindow)主窗口会在市图层次结构中找到一个最合适的视图来处理触摸事件找到合适的视图控件后,就会...
阅读全文
摘要:1 #import 2 @class NJLockView; 3 4 @protocol NJLockViewDelegate 5 6 - (void)lockViewDidClick:(NJLockView *)lockView andPwd:(NSString *)pwd;...
阅读全文
摘要:1 @interface NJView () 2 3 @property (nonatomic, strong) NSMutableArray *paths; 4 5 @end 6 7 @implementation NJView 8 9 - (NSMutableArray *)paths...
阅读全文
摘要:1 @interface NJView () 2 /** 3 * 定义一个大数组(大数组中保存小数组, 每一个小数组保存一条直线所有的点) 4 */ 5 @property (nonatomic, strong) NSMutableArray *totalPoints; 6 ...
阅读全文
摘要:1 - (IBAction)captureView:(UIButton *)sender { 2 3 // 延迟1 ~2 秒之后再截屏 4 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NS...
阅读全文
摘要:1 // 当手指在view上移动的时候调用 2 - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event 3 { 4 5 UITouch *touch = [touches anyObject]; 6 ...
阅读全文
摘要:1 #import 2 3 @interface UIImage (NJ) 4 /** 5 * 生成头像 6 * 7 * @param icon 头像图片名称 8 * @param border 头像边框大小 9 * @param color 头像边框的颜色10 *1...
阅读全文
摘要:1 - (void)drawRect:(CGRect)rect 2 { 3 // 1.获取上下文 4 CGContextRef ctx = UIGraphicsGetCurrentContext(); 5 6 // 2.创建路径(一个path就代表一条路径) 7 ...
阅读全文
摘要:1 @implementation NJView 2 3 /* 4 -(void)awakeFromNib 5 { 6 7 NSLog(@"awakeFromNib"); 8 // 创建CADisplayLink, 默认每秒60次 9 CADisplayLink *di...
阅读全文
摘要:1 - (void)drawRect:(CGRect)rect 2 { 3 // Drawing code 4 5 // 画圆, 以便于以后指定可以显示内容范围 6 CGContextRef ctx = UIGraphicsGetCurrentContext();...
阅读全文
摘要:1 - (void)drawRect:(CGRect)rect 2 { 3 // 画四边形 4 CGContextRef ctx = UIGraphicsGetCurrentContext(); 5 6 // 保存上下文 7 CGContextSaveGS...
阅读全文
摘要:1 - (void)drawRect:(CGRect)rect 2 { 3 // 获取上下文 4 CGContextRef ctx = UIGraphicsGetCurrentContext(); 5 6 // 保存一份最纯洁的图形上下文 7 // 调用一次该方法...
阅读全文
摘要:// controllerX,controllerY是弧形起始点的坐标,endX,endY是结束点的坐标CGContextAddQuadCurveToPoint(ctx, controllerX, controllerY, endX, endY);
阅读全文
摘要:// 1.获取上下文 CGContextRef ctx = UIGraphicsGetCurrentContext(); // 2.画饼状图 // 画线 CGContextMoveToPoint(ctx, 100, 100); CGContextAddLineT...
阅读全文
摘要:1 // 画圆弧 2 // 1.获取上下文 3 CGContextRef ctx = UIGraphicsGetCurrentContext(); 4 // 2.画圆弧 5 // x/y 圆心 6 // radius 半径 7 // start...
阅读全文
摘要:1 - (void)drawRect:(CGRect)rect 2 { 3 4 // 1.获取上下文 5 CGContextRef ctx = UIGraphicsGetCurrentContext(); 6 // 画圆 7 CGContextAddArc(ctx...
阅读全文
摘要:1 // 1.获取图形上下文 2 CGContextRef ctx = UIGraphicsGetCurrentContext(); 3 4 // 2. 绘制三角形 5 // 设置起点 6 CGContextMoveToPoint(ctx, 10...
阅读全文
摘要:1 #import 2 3 @interface NJRectView : UIView 4 @end 5 6 7 #import "NJRectView.h" 8 9 @implementation NJRectView10 11 - (void)drawRect:(CGRect)re...
阅读全文
摘要:1 #import 2 3 @interface NJLineView : UIView 4 @end 5 6 7 #import "NJLineView.h" 8 9 @implementation NJLineView10 11 // 当自定义view第一次显示出来的时候就会调用dr...
阅读全文
摘要:1 @interface NJTextImage : UIView 2 @end 3 4 5 @implementation NJTextImage 6 7 - (void)drawRect:(CGRect)rect 8 { 9 // [self test];10 // ...
阅读全文
摘要:1 #import 2 3 @interface NJContatc : NSObject 4 5 @property (nonatomic, copy) NSString *name; 6 @property (nonatomic, copy) NSString *phoneNumber...
阅读全文
摘要:1 存储数据到NSUserDefaults(偏好设置)中 // 获取NSUserDefaults对象 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; // 保存数据(如果设置数据之后没有同步, 会在将来某一时间点...
阅读全文
摘要:1 用沙盒路径拼接 // 获取应用程序沙河目录 NSString *home = NSHomeDirectory(); // 不建议写/ NSString *path = [home stringByAppendingString:@"/Documents"]; // 不建议Documen...
阅读全文
浙公网安备 33010602011771号