`
文章列表
/** *  返回一张可以随意拉伸不变形的图片 * *  @param name 图片名字 */ + (UIImage *)resizableImage:(NSString *)name {     UIImage *normal = [UIImage imageNamed:name];     CGFloat w = normal.size.width * 0.5;     CGFloat h = normal.size.height * 0.5;     return [normal resizableImageWithCapInsets:UIEdgeInsetsMake(h, w, ...
- (CGSize)sizeWithFont:(UIFont *)font maxSize:(CGSize)maxSize {     NSDictionary *attrs = @{NSFontAttributeName : font};     return [self boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:attrs context:nil].size; }

多长时间后调用

    博客分类:
  • ios
 
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{         [self.delegate tgFootViewDidClickLoadBtn:self];         self.loadBtn.hidden = NO;         self.loadImageView.hidden = YES;     });

给label 设置位矩形

    博客分类:
  • ios
[label.layer setCornerRadius:5]; [label setClipsToBounds:YES];

iOS中两种弹出框

    博客分类:
  • ios
1、从底部弹出 UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"恭喜通关" delegate:nil cancelButtonTitle:@"取消" destructiveButtonTitle:@"确定" otherButtonTitles:@"其他", nil];         [sheet showInView:self.view]; 2、弹出在中间             // 创建弹框         UIAlertVi ...
self.optionView.userInteractionEnabled = NO;

iOS中两种定时器

    博客分类:
  • ios
频率比较高  CADisplayLink 相隔时间较长 NSTimer 注意事项:当前线程正在处理其他事件时,定时器不会执行。可以设置线程的优先级 代码如下 self.timer = [NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(nextImage) userInfo:nil repeats:YES]; [[NSRunLoop currentRunLoop] addTimer:self.timer forMode:NSRunLoopCommonModes];
1、定时器 controller [self performSelector:@selector(nextQuestion:) withObject:nil afterDelay:0.5]; 2、让数组中每个对象调用某个方法 [self.optionsView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)]; 3、将一个图层移到最前面 [self.view bringSubviewToFront:self.iconBtn]; 4、控制状态栏的样式 重写方法 /** *  控制状态栏的样式 */ - ...

iOS day3

    博客分类:
  • ios
1.Xcode自带头文件的路径 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk/System/Library/Frameworks/UIKit.framework/Headers 2.修改了系统自带头文件后,Xcode会报错 解决方案:删掉下面文件夹的缓存即可(aplle是电脑的用户名) /Users/aplle/资源库/Developer/Xcode/DerivedData 或者 /Users/aplle/Li ...
System时长按会变灰色 Custome 不会
Xib文件可以用来描述某一块局部的UI界面 Xib文件的加载 方法1 NSArray *objs = [[NSBundle mainBundle] loadNibNamed:@"MJAppView" owner:nil options:nil]; 这个方法会创建xib中的所有对象,并且将对象按顺序放到objs数组中 (如果xib如右图所示,那么objs数组中依次会有3个对象:1个UIView、1个UIButton、1个UISwitch) 方法2 bundle参数可以为nil,默认就是main bundle UINib *nib = [UINib nibWithNibNam ...

Xib和storyboard对比

    博客分类:
  • ios
共同点: 都用来描述软件界面 都用Interface Builder工具来编辑 不同点 Xib是轻量级的,用来描述局部的UI界面 Storyboard是重量级的,用来描述整个软件的多个界面,并且能展示多个界面之间的跳转关系
instancetype在类型表示上,跟id一样,可以表示任何对象类型 instancetype只能用在返回值类型上,不能像id一样用在参数类型上 instancetype比id多一个好处:编译器会检测instancetype的真实类型

property

    博客分类:
  • ios
copy : NSString strong: 一般对象 weak: UI控件 assign:基本数据类型
UIButton之所以能够显示图片和文字,是因为UIButton中有UIImageView属性和Label属性 设置按钮的文字的大小如下代码: downloadBtn.titleLabel.font = [UIFont systemFontOfSize:13]; 但是设置图片不能直接去Label和UIImageView属性直接进行设置,因为不知道按钮的状态,要用如下代码进行设置:        // 设置默认的背景         UIImage *normalImage = [UIImage imageNamed:@"buttongreen"];         [do ...
Global site tag (gtag.js) - Google Analytics