本文设计了美图秀秀官方版的界面,从中可以学到自定义View,自动布局,启动界面设置。代码有点凌乱,我在一步步改善。【声明:本博客只能用作学习用途,不得用于商业用途,图片资源均来自官方,产生纠纷,本人不负责】

项目中的图片资源均来自官方版的下载包中的图片(原始图片),这样我们可以通过模仿成功案例来学习iOS开发。[刚更新了项目下载地址,如需下载请滑到最下面点击项目下载.关于屏幕适配已更新]

  项目结构及介绍

  

category组中存放对类的扩展

Utiles中存放一些常用的代码

controller中存放viewController文件

network存放访问网络的工具类

3rd lib存放项目中使用到的第三方类库

views存放自定义视图

models存放数据类

images存放项目中的图片资源

  应用程序图标设置

使用XCODE打开Images.xcassets文件,编辑AppIcon,如下图

具体图标要求请参见苹果官方文档

这样我们就设置了应用程序在桌面中的显示图标

  启动界面设置

  

  1.使用XCODE打开Images.xcassets文件,编辑LaunchImage,拖放具体图片资源。具体图标要求请参见苹果官方文档

  2.修改AppDelegate

  

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {// Override point for customization after application launch.[NSThread sleepForTimeInterval:10.0];//    [application setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade];return YES;
}

在 application: didFinishLaunchingWithOptions:方法中添加

[NSThread sleepForTimeInterval:10.0];

10.0说明启动界面将持续10秒,一般我们设置为3.0就ok。可以根据你的需求来设置启动界面的时常。

 

  首页界面设计

      

我将首页拆分为几个独立的视图,分别为

                 

图一为简单的UIImageView对象 ,图二为自定义视图。图三为UIScrollView对象中包含8个自定义按钮,图四为简单的button,图五为简单的pageControl,图六为简单的button。适应多种分辨率。下面是Autolayout实现

 [self.view addConstraints:@[[NSLayoutConstraint constraintWithItem:self.topView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTop multiplier:1.0 constant:0],[NSLayoutConstraint constraintWithItem:self.topView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeRight multiplier:1.0 constant:-6],[NSLayoutConstraint constraintWithItem:self.topView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:51],[NSLayoutConstraint constraintWithItem:self.topView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:61],[NSLayoutConstraint constraintWithItem:btnSetting attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeBottom multiplier:1.0 constant:-8],[NSLayoutConstraint constraintWithItem:btnSetting attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeRight multiplier:1.0 constant:-6],[NSLayoutConstraint constraintWithItem:btnSetting attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:39],[NSLayoutConstraint constraintWithItem:btnSetting attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:btnSetting attribute:NSLayoutAttributeWidth multiplier:1.0 constant:0],[NSLayoutConstraint constraintWithItem:self.scrolleView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:image attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0],[NSLayoutConstraint constraintWithItem:self.scrolleView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0],[NSLayoutConstraint constraintWithItem:self.scrolleView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:WIDTH],[NSLayoutConstraint constraintWithItem:self.scrolleView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:HEIGHT - 47 - 61]]];

按钮的分页显示实现

    for (int i = 0; i < 8; i++) {NSInteger row  = i % 2;NSInteger col  = i / 2;NSInteger page = i / 6;if (col == 3) {col = 0;}btnHome = [FWButton buttonWithType:UIButtonTypeCustom];[btnHome setTitle:[textArr objectAtIndex:i] forState:UIControlStateNormal];[btnHome setImage:[UIImage imageNamed:[imageViewImageArr objectAtIndex:i]] forState:UIControlStateNormal];[btnHome setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:[imageViewBackImageArr objectAtIndex:i]]]];[btnHome setBackgroundColorHighlighted:[UIColor colorWithPatternImage:[UIImage imageNamed:[highLightedBackImageArr objectAtIndex:i]]]];
//        btnHome.frame =CGRectMake([(NSString *)[xArr objectAtIndex:i] floatValue], [(NSString *)[yArr objectAtIndex:i] floatValue], kWidth, kheight);btnHome.frame = CGRectMake(row * (kWidth + kPadding) + page * WIDTH + startX, col * (kHeight + kPadding) + startY, kWidth, kHeight);[btnHome.titleLabel setFont:[UIFont systemFontOfSize:14]];[btnHome addTarget:self action:@selector(btnClicked:) forControlEvents:UIControlEventTouchUpInside];btnHome.topPading = 0.5;[self.scrolleView addSubview:btnHome];self.scrolleView.contentSize = CGSizeMake(WIDTH * 2, kHeight * 3 + kPadding * 2);}

主界面实现

//
//  ViewController.m
//  FWMeituApp
//
//  Created by ForrestWoo on 15-9-16.
//  Copyright (c) 2015年 ForrestWoo co,.ltd. All rights reserved.
//375*667#define kLeftOffset  42
#define kRightOffset 42
#define kPadding     10
#define kWidth       103
#define kHeight      105#import "ViewController.h"
#import "FWTopView.h"
#import "FWButton.h"
#import "UIImage+ImageScale.h"@interface ViewController ()
@property (nonatomic, strong) FWTopView *topView;
@property (nonatomic, assign)   CGRect     leftArrowFrame;
@property (nonatomic, assign)   CGRect     rightArrowFrame;
@end@implementation ViewController- (void)viewDidLoad
{[super viewDidLoad];self.navigationController.delegate = self;UIImageView *backImage = [[UIImageView alloc] initWithFrame:self.view.bounds];backImage.image = [UIImage imageNamed:@"bg_home@2x.jpg"];[self.view addSubview:backImage];self.scrolleView = [[UIScrollView alloc] init];self.scrolleView.translatesAutoresizingMaskIntoConstraints = NO;self.scrolleView.pagingEnabled = YES;self.scrolleView.showsHorizontalScrollIndicator = NO;self.scrolleView.showsVerticalScrollIndicator = NO;self.scrolleView.delegate = self;[self.view addSubview:self.scrolleView];UIImageView *image = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bg_topview_topback_a.png"]];image.frame = CGRectMake(15, 15, 226.5, 51.5);[self.view addSubview:image];self.rightArrowFrame = CGRectMake(WIDTH - 30, HEIGHT / 2 - 50 / 2, 30, 50);self.leftArrowFrame = CGRectMake(5, HEIGHT / 2 - 50 / 2, 30, 50);btnArrow = [UIButton buttonWithType:UIButtonTypeCustom];btnArrow.frame = self.rightArrowFrame;[btnArrow setImage:[UIImage imageNamed:@"right_arrow@2x.png"] forState:UIControlStateNormal];[btnArrow setImage:[UIImage imageNamed:@"right_arrow_highlight@2x.png"] forState:UIControlStateHighlighted];[btnArrow addTarget:self action:@selector(btnArrowClicked:) forControlEvents:UIControlEventTouchUpInside];[self.view addSubview:btnArrow];//width = 51,height = 61.self.topView = [[FWTopView alloc] init];[self.view addSubview:self.topView];self.topView.translatesAutoresizingMaskIntoConstraints = NO;//width,height = 39UIButton *btnSetting = [UIButton buttonWithType:UIButtonTypeCustom];//    btnSetting.frame = CGRectMake(330, 620, 39, 39);[btnSetting setImage:[UIImage imageNamed:@"btn_home_setting_a@2x.png"] forState:UIControlStateNormal];[self.view addSubview:btnSetting];btnSetting.translatesAutoresizingMaskIntoConstraints = NO;[self.view addConstraints:@[[NSLayoutConstraint constraintWithItem:self.topView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTop multiplier:1.0 constant:0],[NSLayoutConstraint constraintWithItem:self.topView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeRight multiplier:1.0 constant:-6],[NSLayoutConstraint constraintWithItem:self.topView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:51],[NSLayoutConstraint constraintWithItem:self.topView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:61],[NSLayoutConstraint constraintWithItem:btnSetting attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeBottom multiplier:1.0 constant:-8],[NSLayoutConstraint constraintWithItem:btnSetting attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeRight multiplier:1.0 constant:-6],[NSLayoutConstraint constraintWithItem:btnSetting attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:39],[NSLayoutConstraint constraintWithItem:btnSetting attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:btnSetting attribute:NSLayoutAttributeWidth multiplier:1.0 constant:0],[NSLayoutConstraint constraintWithItem:self.scrolleView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:image attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0],[NSLayoutConstraint constraintWithItem:self.scrolleView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0],[NSLayoutConstraint constraintWithItem:self.scrolleView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:WIDTH],[NSLayoutConstraint constraintWithItem:self.scrolleView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:HEIGHT - 47 - 61]]];[self.topView initView:@"20"];self.pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake((WIDTH - 50) / 2, HEIGHT - 39 , 50, 10)];self.pageControl.numberOfPages = 2;[self.view addSubview:self.pageControl];[self setupScrollView];
}- (void)viewWillAppear:(BOOL)animated
{[[UIApplication sharedApplication] setStatusBarHidden:YES];
}//
- (void)hanlderAction:(NSTimer *)timer
{//    if (btnArrow.image.] == UIControlStateHighlighted)//    {//    }
}- (void)btnArrowClicked:(id)sender
{if (self.pageControl.currentPage ) {self.pageControl.currentPage = 0;[self toLeftArrow];}else{self.pageControl.currentPage = 1;[self toRightArrow];}CGRect frame = self.scrolleView.frame;frame.origin.x = frame.size.width * self.pageControl.currentPage;[self.scrolleView scrollRectToVisible:frame animated:YES];
}- (void)toRightArrow
{btnArrow.frame = self.leftArrowFrame;[btnArrow setImage:[UIImage imageNamed:@"left_arrow@2x.png"] forState:UIControlStateNormal];
}- (void)toLeftArrow
{btnArrow.frame = self.rightArrowFrame;[btnArrow setImage:[UIImage imageNamed:@"right_arrow@2x.png"] forState:UIControlStateNormal];
}- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{int index = fabs(self.scrolleView.contentOffset.x / self.scrolleView.frame.size.width) ;self.pageControl.currentPage = index;if (index){[self toRightArrow];}else{[self toLeftArrow];}}- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
}- (void)setupScrollView
{NSArray *imageViewImageArr = [NSArray arrayWithObjects:@"icon_home_beauty@2x.png", @"icon_home_cosmesis@2x.png", @"icon_home_puzzle@2x.png",@"icon_home_camera@2x.png", @"icon_home_material@2x.png", @"icon_home_meiyan@2x.png",@"icon_home_meipai@2x.png", @"icon_home_moreapp@2x.png",nil];NSArray *highLightedBackImageArr = [NSArray arrayWithObjects:@"home_block_red_b@2x.png", @"home_block_pink_b@2x.png", @"home_block_green_b@2x.png",@"home_block_orange_b@2x.png", @"home_block_blue_b@2x.png", @"item_bg_purple_b@2x.png",@"home_block_pink_b@2x.png", @"home_block_red_b@2x.png",nil];NSArray *imageViewBackImageArr = [NSArray arrayWithObjects:@"home_block_red_a@2x.png", @"home_block_pink_a@2x.png", @"home_block_green_a@2x.png",@"home_block_orange_a@2x.png", @"home_block_blue_a@2x.png", @"item_bg_purple_a@2x.png",@"home_block_pink_a@2x.png", @"home_block_red_a@2x.png",nil];NSArray *textArr = [NSArray arrayWithObjects:@"美化图片", @"人像美容", @"拼图", @"万能相机", @"素材中心", @"美颜相机", @"美拍", @"更多功能", nil];FWButton *btnHome = nil;CGFloat startX = WIDTH /  2 - kPadding / 2 - kWidth;CGFloat startY = HEIGHT / 2 - kPadding - kHeight / 2 - kHeight -  61;for (int i = 0; i < 8; i++) {NSInteger row  = i % 2;NSInteger col  = i / 2;NSInteger page = i / 6;if (col == 3) {col = 0;}btnHome = [FWButton buttonWithType:UIButtonTypeCustom];[btnHome setTitle:[textArr objectAtIndex:i] forState:UIControlStateNormal];[btnHome setImage:[UIImage imageNamed:[imageViewImageArr objectAtIndex:i]] forState:UIControlStateNormal];[btnHome setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:[imageViewBackImageArr objectAtIndex:i]]]];[btnHome setBackgroundColorHighlighted:[UIColor colorWithPatternImage:[UIImage imageNamed:[highLightedBackImageArr objectAtIndex:i]]]];
//        btnHome.frame =CGRectMake([(NSString *)[xArr objectAtIndex:i] floatValue], [(NSString *)[yArr objectAtIndex:i] floatValue], kWidth, kheight);btnHome.frame = CGRectMake(row * (kWidth + kPadding) + page * WIDTH + startX, col * (kHeight + kPadding) + startY, kWidth, kHeight);[btnHome.titleLabel setFont:[UIFont systemFontOfSize:14]];[btnHome addTarget:self action:@selector(btnClicked:) forControlEvents:UIControlEventTouchUpInside];btnHome.topPading = 0.5;[self.scrolleView addSubview:btnHome];self.scrolleView.contentSize = CGSizeMake(WIDTH * 2, kHeight * 3 + kPadding * 2);}
}- (void)btnClicked:(id)sender
{if ([[(UIButton *)sender titleLabel].text isEqualToString:@"美化图片"]) {if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]){imagePicker = [[UIImagePickerController alloc] init];imagePicker.delegate = self;imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;[self presentViewController:imagePicker animated:YES completion:^{[[UIApplication sharedApplication] setStatusBarHidden:YES];}];}}}#pragma mark - UIImagePickerControllerDelegate
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{UIImage *selectedImage = [info objectForKey:@"UIImagePickerControllerOriginalImage"];UIImage *image = [UIImage imageCompressForWidth:selectedImage targetWidth:375];if (image.size.height > 520) {image = [UIImage imageCompressForWidth:selectedImage targetHeight:520];}currentImage = image;beautyVC = [[FWBeautyViewController alloc] initWithImage:currentImage];[imagePicker pushViewController:beautyVC animated:YES];}- (UIImage *)imageWithImageSimple:(UIImage *)image scaleToSize:(CGSize)Newsize
{UIGraphicsBeginImageContext(Newsize);[image drawInRect:CGRectMake(0, 0, Newsize.width, Newsize.height)];UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();UIGraphicsEndImageContext();return newImage;
}- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{[self dismissViewControllerAnimated:imagePicker completion:^{}];
}@end

#define WIDTH [UIScreen mainScreen].bounds.size.width
#define HEIGHT [UIScreen mainScreen].bounds.size.height

代码凌乱,正在逐步改善。。。。。。

下载项目

转载于:https://www.cnblogs.com/salam/p/5071738.html

美图秀秀首页界面设计(一)相关推荐

  1. 美图秀秀首页界面按钮设计(二)

    本文实现美图秀秀首页中的按钮,它包含3张图片和一个文本.通过开发按钮,我们可以学到iOS的自定义控件,绘制图片和文本的知识.[声明:本博客只能用作学习用途,不得用于商业用途,图片资源均来自官方,产生纠 ...

  2. MATLAB美图秀秀系统GUI设计[完美运行,GUI界面,详细教程,万字文稿]

    课题名称 基于MATLAB的美图秀秀系统GUI设计 GUI框架链接:matlab美图秀秀[GUI,磨皮,白平衡,特效].zip_matlabGUI制作美图秀秀界面-专业指导文档类资源-CSDN下载 课 ...

  3. 小学计算机学情分析报告,美图小学信息技术_秀秀美图更漂亮教学设计学情分析教材分析课后反思...

    第2课秀秀美图更漂亮 教学目的和要求 1. 了解美图秀秀的基本功能及操作方法 2. 能够用美图秀秀对照片进行简单的美化 3. 通过照片美化活动提高自己的审美水平增加生活的趣味. 教学重点与难 ...

  4. android 相机智能补光,美图秀秀智能补光功能应用详解

    晚上拍照时最容易遇见"曝光不足"和"曝光过度"的问题,使得照片看起来明暗不协调,缺乏应有的美感.不过,如果你的手机中 装有"美图秀秀",这些 ...

  5. 十行代码,我用Python做一个迷你版的美图秀秀!

    美图秀秀相信大家都不陌生,大家只要操作美图秀秀,就可以P掉图片中脸上的一些瑕疵,让人变得更加的美丽.今天小编就带领大家来借助Python和Flask来实现一个美图秀秀的网页设计,大家只需要通过网页上传 ...

  6. 美图秀秀想让妹纸留下来分享美图,社交梦能如愿以偿吗?

    日前美图秀秀开始内测名为"MT社交圈"的新功能,我受邀参加内测,体验发现这是一款基于图片和短视频内容的社区,用户可以发布图片和短视频两类内容,可以对他人的内容进行点赞.评论和转发, ...

  7. 十行代码,用Python做一个迷你版的美图秀秀

    美图秀秀相信大家都不陌生,大家只要操作美图秀秀,就可以P掉图片中脸上的一些瑕疵,让人变得更加的美丽.今天小编就带领大家来借助Python和Flask来实现一个美图秀秀的网页设计,大家只需要通过网页上传 ...

  8. python 制作自己的新闻_新闻-十行代码,用Python做一个迷你版的美图秀秀

    十行代码,用Python做一个迷你版的美图秀秀 2020-02-28 10:16:08 作者: 匿名 浏览量:65次 美图秀秀相信大家都不陌生,大家只要操作美图秀秀,就可以P掉图片中脸上的一些瑕疵,让 ...

  9. python 两点曲线_十行代码,用Python做一个迷你版的美图秀秀

    美图秀秀相信大家都不陌生,大家只要操作美图秀秀,就可以P掉图片中脸上的一些瑕疵,让人变得更加的美丽.今天小编就带领大家来借助Python和Flask来实现一个美图秀秀的网页设计,大家只需要通过网页上传 ...

最新文章

  1. 田志刚北京大学CIO(信息总监)班讲知识管理
  2. 制作ubuntu16.04的docker镜像
  3. MATLAB从入门到精通:Simulink仿真必看——连续模块之PID控制器(PID Controller)
  4. 亚信安全与安徽电信共创“云网融合”安全新局面
  5. leetcode 75 --- sort-colors
  6. 解决北京户口,中科院计算所校招,CV/图像处理工程师,博士优先
  7. C#下实现的K-Means优化[1]-「离群点检测」
  8. Mosquitto感知客户端上下线的方法
  9. 【Java】Java SimpleDateFormat 线程安全 问题
  10. Postdoctoral Position
  11. 影子之美!太阳日照阴影变化之计算模拟
  12. 利用BS爬取单词音标
  13. python实现单例模式的几种方法实例详解
  14. 清华梦的粉碎—写给清华大学的退学申请(转自王垠Blog)
  15. 5G时代下的人工智能发展
  16. snort 轻量级入侵检测系统安装与使用
  17. 人工智能如何自己玩游戏?
  18. js版【微信机器人】——wechat-robot
  19. 考研结束大半年,研0这些时间普通人的一些感触(附开学flag)
  20. GPS定位中的误差源及解决方法

热门文章

  1. php move函数,PHP中move_uploaded_file() 函数详解
  2. jdbc mysql 成功 spring mysql 失败_java Spring 的JDBCTemplet批量入库数据时如果有一条数据入库不成功,其他的数据还会入库吗...
  3. 毕业设计 STM32的智能WIFI视频人脸追踪监控系统
  4. mysql数据库连接不释放问题
  5. linux下impdp导入数据,impdp 导入的用法!
  6. C# await 高级用法
  7. gd32F103C8T6 flash填坑
  8. Pyinstaller打包 Pytest+Allure成exe文件执行时,报error: unrecognized arguments: --count=1,--alluredir=result错
  9. java在linux下新建文件夹
  10. 交通银行万事达Y-POWER信用卡 普卡