轻松搭建新特性界面、向导页
1、应用场景新软件安装在第一次打开时都会有该软件或版本的介绍,在iOS中最经典的做法是搭建一个ScrollView分页展示
但考虑到iPhone4系统与iPhone5系统,屏幕适配如何更为科学简单是一门学问,以下提供一个参考
2、图片命名
一般是三图片,Retina屏之前屏幕一套、iPhone4(4S)一套、iPhone5(5C/5S)一套
xxx_序号.png // iPhone3GS及以前,可忽略
xxx_序号@2x.png // iPhone4及iPhone4S
xxx_序号[email protected]// iPhone5及iPhone5C、iPhone5S
如:
new_feature_1.png
[email protected]
[email protected]
new_feature_2.png
[email protected]
[email protected]
new_feature_3.png
[email protected]
[email protected]
3、文件名自动识别3.1、增加两个Category
NSString+SA
//
//NSString+SA.m
//SianWeibo
//
//Created by yusian on 14-4-12.
//Copyright (c) 2014年 小龙虾论坛. All rights reserved.
//自定义字符串拼接方法
#import "NSString+SA.h"
@implementation NSString (SA)
- (NSString *)fileAppend:(NSString *)string
{
// 1、获取文件扩展名
NSString *ext = ;
// 2、去掉文件扩展名
NSString *str = ;
// 3、拼接新加字符串
str = ;
// 4、拼接扩展名
str = ;
return str;
}
@endUIImage+SA
//
//UIImage+SA.m
//SianWeibo
//
//Created by yusian on 14-4-11.
//Copyright (c) 2014年 小龙虾论坛. All rights reserved.
//
// 判断是否为iphone5的宏
#define isIPhone5 (.bounds.size.height == 568)
#import "UIImage+SA.h"
#import "NSString+SA.h"
@implementation UIImage (SA)
+ (UIImage *)fullScreenImage:(NSString *)string
{
// 根据屏幕高度判断iphone5
if (isIPhone5) {
string = ;
}
return ;
}
// 自动拉伸图片
+ (UIImage *)resizeImage:(NSString *)imageName
{
UIImage *image = ;
return ;
}
@end
4、创建ScrollView(关键代码)
#pragma mark 2.1、添加scrollView控件
- (UIScrollView *)creatScrollView // 控件的创建单独抽象成方法
{
// 创建scrollView设置尺寸位置及相关属性
UIScrollView *scrollView = [ init];
scrollView.frame = self.view.bounds;
scrollView.contentSize = CGSizeMake(_size.width * kPicCount, 0);
scrollView.pagingEnabled = YES;
scrollView.showsHorizontalScrollIndicator = NO;
scrollView.delegate = self;
//创建新特性图片设置尺寸位置并添加到scrollView
for (int i = 0; i < kPicCount; i++) {
UIImageView *imageView = [ init];
;
NSString *imageName = ;
imageView.image = ;
imageView.frame = CGRectMake(_size.width * i, 0, _size.width, _size.height);
}
return scrollView;
}
页:
[1]