继续创作,加快生长!这是我参加「日新方案 6 月更文挑战」的第37天,点击查看活动概况

引言

  • 提交app store的时候 需要一张1024*1024的

  • 假如不设置这两种的尺度启动页的话,在4英寸、3.5英寸的设备上展示不了启动页,app 的高度也默许都是矮的960px.**

    iOS小技能:iOS中点与像素的关系 (retina 屏幕下的点= 像素/2)

  • 注意@3x 提供给开发的px 为12422208 ,但实在的px 是10801920,体系API会主动进行等比例缩小;

I iOS中点与像素有什么联系?

  1. 点是iOS中规范的坐标体系。它便是iOS中的虚拟像素,也被称为逻辑像素。 在规范设备中,一个点便是一个像素,可是在Ratina屏幕上,一个点等于22个像素。iOS用点作为屏幕的坐标测算体系便是为了在Retina设备和普通设备上能有一致的视觉效果。
  2. 像素是图片分辨率的尺度单位。物理像素坐标并不会用于屏幕布局,可是依然和图片有相对联系。

retina 屏幕下的点= 像素/2。

II 图片运用的相重视意事项

2.1 引荐运用png格局

  1. png: 常常放置于Assets.xcassets目录中,作为控件的背景图片。

紧缩 较高,无损紧缩,解压效率高,对CPU耗费少

  1. jpg, 常常放置于Supporting Files目录

1)紧缩比 比较高,通常用于相片、网页

2)属于有损紧缩(噪点noise)

3)解压时对cpu 耗费大--意味着,慢、费电

2.2 关于图像的实例化

办法一:有缓存加载图片


+ (UIImage *)imageNamed:(NSString *)name 体系引荐运用的办法,但图像实例化之后的目标开释由体系担任。
//       [arrayImage addObject: [UIImage imageNamed:pictureNamePrefix]];//参数为图片称号,png 格局的可以不加扩展名

办法二:无缓存办法加载图片(提示、假如放置于Assets.xcassets目录中的图片不能运用imageWithContentsOfFile:path进行加载;只能运用imageName进行加载,即内存由体系担任了)

//办法二:无缓存办法加载图片-指定扩展名
//        NSArray *arrayPicture = [pictureNamePrefix componentsSeparatedByString:@"."];//从字符平分隔成2个元素的数组(图片名+扩展名)
//        NSString *path = [[NSBundle mainBundle] pathForResource:arrayPicture[0] ofType: arrayPicture[1]];//获取图片的全路径
        //办法二:无缓存办法加载图片-不指定扩展名
        NSString *path = [[NSBundle mainBundle] pathForResource:pictureNamePrefix ofType:nil];
        [arrayImage addObject:[ UIImage imageWithContentsOfFile:path]];

/Users/devzkn/Library/Developer/CoreSimulator/Devices/949ED3EA-A51B-4B5C-99B1-8069EB99E684/data/Containers/Bundle/Application/2B2B99A6-4FBC-4171-BE4F-ECA1B5AA2590/09-tomcat.app/angry_00.jpg

iOS小技能:iOS中点与像素的关系 (retina 屏幕下的点= 像素/2)

2.3 动画完毕之后铲除帧动画数组

{      //开始动画
    [self.imageList startAnimating];
    //开释资源:动画完毕之后铲除帧动画数组
    //nvokes a method of the receiver on the current thread using the default mode after a delay.
    [self performSelector:@selector(cleanUpAnimationsArray) withObject:nil afterDelay:self.imageList.animationDuration];//@interface NSObject (NSDelayedPerforming)
}
- (void)cleanUpAnimationsArray{
    NSLog(@"%s ",__func__);
    //动画完毕之后铲除帧动画数组
    [self.imageList setAnimationImages:nil];
}

铲除内存的代码简化

 [self.imageList performSelector:@selector(setAnimationImages:) withObject:nil afterDelay:self.imageList.animationDuration];

III 设置状态栏字体颜色

3.1 办法一

  1. 在info.plist中,将View controller-based status bar appearance设为NO.
  2. 在app delegate中:[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;

3.2 办法二

  1. VC中重写 -(UIStatusBarStyle)preferredStatusBarStyle 2、在viewDidload中调用:[self setNeedsStatusBarAppearanceUpdate];

可是:当vc在nav中时,上面办法没用,vc中的preferredStatusBarStyle办法根本不必被调用。 原因是,[self setNeedsStatusBarAppearanceUpdate]宣布后,只会调用navigation controller中的preferredStatusBarStyle办法,vc中的preferredStatusBarStyley办法跟本不会被调用。

解决办法:self.navigationController.navigationBar.barStyle = UIBarStyleBlack; 或者界说一个nav bar的子类,在这个子类中重写preferredStatusBarStyle办法:

see also

CFBundleAllowMixedLocalizations 敞开体系预界说的本地化功用


<key>CFBundleAllowMixedLocalizations</key>
 <true/>

更多内容请重视 #小程序:iOS逆向,只为你出现有价值的信息,专心于移动端技术研究领域;更多服务和咨询请重视#公众号:iOS逆向