ViewController 应用

 
再第一个XIB页面创建另一个XIB页面,并且通过按钮调用它
 
 
- (IBAction)GoSecond:(id)sender {
    secondViewController *secVC = [[secondViewController alloc] initWithNibName:@"secondViewController" bundle:nil];
    secVC.modalTransitionStyle = UIModalPresentationPageSheet;
    [self presentViewController:secVC animated:YES completion:^{
        NSLog(@"success ");
    }];
}
 
在第二个XIB页面创建一个按钮,按钮PRESS返回第一个页面
 
 
- (IBAction)Backfirst:(id)sender {
    [self dismissViewControllerAnimated:YES completion:^{
        NSLog(@"dismiss");
    }];
}
 
 
创造生命周期函数:
 
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    NSLog(@"view will appear");
}
-(void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
    NSLog(@"view did appear");
}
-(void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    NSLog(@"view will disappear");
}
-(void)viewDidDisappear:(BOOL)animated{
    [super viewDidDisappear:animated];
    NSLog(@"view did disappear");
}
 
 
页面切换方法:
 
       secVC.modalTransitionStyle = UIModalPresentationPageSheet;
    UIModalPresentationFullScreen = 0,
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_3_2
    UIModalPresentationPageSheet,
    UIModalPresentationFormSheet,
    UIModalPresentationCurrentContext,
#endif
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_7_0
    UIModalPresentationCustom,
    UIModalPresentationNone = -1,   
 
 
 
 
做成如下图片,类型:
 
 
 
 
主视图代码:
 
#import "UserModel.h"
@interface Xib_1 : UIViewController
@property (nonatomic, weak) UserModel *model;
-(void)sentRegistMessage:(UserModel *)user;
@end
 
 
- (IBAction)FirstButton:(id)sender {
    Xib_2 *xib2 = [[Xib_2 alloc] initWithNibName:@"Xib_2" bundle:nil];
    xib2.parentVC = self;
    xib2.modalTransitionStyle = UIModalPresentationPageSheet;
    [self presentViewController:xib2 animated:YES completion:^{
        
    }];
}
 
-(void)sentRegistMessage:(UserModel *)user{
    self.Label_1.text = [NSString stringWithFormat:@"恭喜,注册成功,用户名:%@,密码:%@,请牢记,谢谢合作。", user.name, user.pass];
    self.Label_1.numberOfLines = 0;
}
 
 
XIB2:
 
#import "Xib_1.h"

@interface Xib_2 : UIViewController
@property (nonatomic, weak) Xib_1 *parentVC;
@end
 
- (IBAction)Button_submit:(id)sender {
    UserModel *model = [[UserModel alloc] init];
    model.name = _nameLabel.text;
    model.pass = _passLabel.text;
    [self.parentVC sentRegistMessage:model];
    [self dismissViewControllerAnimated:YES completion:^{
    }];
}
 
 
UserModel:
 
@interface UserModel : NSObject
@property (nonatomic, copy)NSString *name;
@property (nonatomic, copy)NSString *pass;
@end
 
用协议可以限制权限:
 
 
 
小球移动的动画:
 
 
@implementation QFAppDelegate{
    UIView *redView;
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    //动画
    redView=[[UIView alloc]initWithFrame:CGRectMake(100, 100, 100, 100)];
    redView.backgroundColor=[UIColor redColor];
    [self.window addSubview:redView];
   
    UIButton *button=[UIButton buttonWithType:UIButtonTypeCustom];
    [button setTitle:@"开始动画" forState:UIControlStateNormal];
    [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [button addTarget:self action:@selector(startAnim:) forControlEvents:UIControlEventTouchUpInside];
    button.frame=CGRectMake(100, 400, 100, 44);
    [self.window addSubview:button];

self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    return YES;
}
-(void)startAnim:(id)sender{
    [UIView animateWithDuration:1 animations:^{
        redView.frame=CGRectMake(100, 300, 150, 150);//大小位置
        redView.transform=CGAffineTransformMakeRotation(M_PI_4);//角度
    } completion:^(BOOL finished) {
        if (finished) {
            [UIView animateWithDuration:2 animations:^{
                redView.transform=CGAffineTransformIdentity;//把变形还原
                redView.frame=CGRectMake(100, 100, 100, 100);
            }];
        }
    }];
}

 
 
如图,做一个三本书旋转的动画例子:
 
 
 
通过animateWithDuration:animations方法来实现动画旋转效果,方便,快捷!
 
 
代码如下:
 
- (void)viewDidLoad
{
    
    [super viewDidLoad];
    [self begin];
    // Do any additional setup after loading the view from its nib.
}

-(void)begin
{
    imageView_3 = [[UIImageView alloc] initWithFrame:CGRectMake(30, 50, 100, 150)];
    imageView_2 = [[UIImageView alloc] initWithFrame:CGRectMake(200, 50, 100, 150)];
    imageView_1 = [[UIImageView alloc] initWithFrame:CGRectMake(80, 110, 140, 200)];

imageView_1.image = [UIImage imageNamed:[NSString stringWithFormat:@"1.jpg"]];
    imageView_2.image = [UIImage imageNamed:[NSString stringWithFormat:@"2.jpg"]];
    imageView_3.image = [UIImage imageNamed:[NSString stringWithFormat:@"3.jpg"]];

[_Subview addSubview:imageView_1];
    [_Subview addSubview:imageView_2];
    [_Subview addSubview:imageView_3];
    [_Subview bringSubviewToFront:imageView_1];

}
- (IBAction)PrePress:(id)sender {
    [UIView animateWithDuration:1 animations:^{
        [_Subview sendSubviewToBack:imageView_3];
        imageView_1.frame = CGRectMake(30, 50, 100, 150);
        imageView_2.frame = CGRectMake(80, 110, 140, 200);
        imageView_3.frame = CGRectMake(200, 50, 100, 150);
    }completion:^(BOOL finished) {
        //imageView_2.frame = CGRectMake(30, 50, 100, 150);
        [_Subview bringSubviewToFront:imageView_2];
        UIImageView *tmp;
        tmp = imageView_1;
        imageView_1 = imageView_2;
        imageView_2 = imageView_3;
        imageView_3 = tmp;
    }];

}
- (IBAction)NextPress:(id)sender {
    
    [UIView animateWithDuration:1 animations:^{
        [_Subview sendSubviewToBack:imageView_2];
        imageView_1.frame = CGRectMake(200, 50, 100, 150);
        imageView_2.frame = CGRectMake(30, 50, 100, 150);
        imageView_3.frame = CGRectMake(80, 110, 140, 200);
    }completion:^(BOOL finished) {
        imageView_2.frame = CGRectMake(30, 50, 100, 150);
        [_Subview bringSubviewToFront:imageView_3];
        UIImageView *tmp;
        tmp = imageView_1;
        imageView_1 = imageView_3;
        imageView_3 = imageView_2;
        imageView_2 = tmp;
    }];
}

 
 
 
 
 
 
 
 
 
 

IOS UI 第四篇:基本UI的更多相关文章

  1. 环信 之 iOS 客户端集成四:集成UI

    在Podfile文件里加入 pod 'EaseUI', :git => 'https://github.com/easemob/easeui-ios-cocoapods.git' 然后在终端中的 ...

  2. 环信 之 iOS 客户端集成四:集成UI 之 会话列表

    1. 初始化 EaseConversationListViewController *chatListVC = [[EaseConversationListViewController alloc] ...

  3. IOS设计模式第四篇之装饰设计模式的类别设计模式

    装饰设计模式 装饰设计模式动态的添加行为和责任向一个对象而不修改他的任何代码.他是你子类化修改类的行为用通过另一个对象的包装的代替方法. 在Objective-c里面有很多这种设计模式的实现,像cat ...

  4. UGUI的优点新UI系统四 开源

    UGUI的优点新UI系统四 开源 新UI系统是开源的,所以开发者可以看到新UI系统实现的源码,并加以修改和使用. 开源授权协议——MIT/X11 Unity所搭载的新UI系统,是在开源授权协议MIT/ ...

  5. iOS进阶指南试读之UI篇

    iOS进阶指南试读之UI篇 UI篇 UI是一个iOS开发工程师的基本功.怎么说?UI本质上就是你调用苹果提供给你的API来完成设计师的设计.所以,想提升UI的功力也很简单,没事就看看UIKit里的各个 ...

  6. 四核驱动的三维导航—淘宝新UI(设计篇)

    前面有一篇博客说到了淘宝UWP的"四核驱动的三维导航—淘宝新UI(需求分析篇)",花了两周的时间实现了这个框架,然后又陆陆续续用了三周的时间完善它. 多窗口导航,与传统的导航方式的 ...

  7. IOS UI 第八篇:基本UI

    实现图片的滚动,并且自动停止在每张图片上     - (void)viewDidLoad{    [super viewDidLoad]; UIScrollView *scrollView = [[U ...

  8. Android异步处理系列文章四篇之一使用Thread+Handler实现非UI线程更新UI界面

    目录: Android异步处理一:使用Thread+Handler实现非UI线程更新UI界面Android异步处理二:使用AsyncTask异步更新UI界面Android异步处理三:Handler+L ...

  9. 游戏模块分析总结(2)之UI、操作篇

    转自:http://www.gameres.com/309812.html 游戏模块分析总结(2)之UI.操作篇 发布者: wuye | 发布时间: 2014-12-12 15:03| 评论数: 0 ...

随机推荐

  1. C语言优化实例:为了消除嵌套switch-case聪明的做法

    我们有可能会写出或者遇到类似这种代码: C/C++ switch (expr1) { case label11: switch (expr2) { case label21: // do someth ...

  2. Ubuntu环境下的Redis 配置与C++使用入门

      Redis是一个高性能的key-value数据库. Redisedis的出现,非常大程度补偿了memcached这类key/value存储的不足,在部分场合能够对关系数据库起到非常好的补充作用.它 ...

  3. 使用ArcGIS API for Silverlight实现地形坡度在线分析

    原文:使用ArcGIS API for Silverlight实现地形坡度在线分析 苦逼的研究生课程终于在今天结束了,也许从今以后再也不会坐在大学的课堂上正式的听老师讲课了,接下来的时间就得开始找工作 ...

  4. Openstack & Hadoop结合项目Sahara

    Openstack 项目Sahara,主要是用来搭建Hadoop集群,利用虚拟出来的计算资源,高速搭建Hadoop集群. Sahara项目与OPenstack其它项目的关系: 图片转自:http:// ...

  5. 【Python】Python与文本处理langid工具包的文本语言检测和歧视

    1.问题的叙述性说明 使用Python文本处理.文字有时被包括中国.英语.在日本和其他语言文字,进行处理.这个时候就须要判别当前文本是属于哪个语系的. Python中有个langid工具包提供了此功能 ...

  6. 部署中遇到的问题-UWSGI(一)

    假设uwsgi错误中提示 *** no app loaded. going in full dynamic mode *** 运行 [plain] view plaincopy aptitude in ...

  7. WCF常见问题(1) -- WebService/WCF Session Cookie

    原文:WCF常见问题(1) -- WebService/WCF Session Cookie 在.net 3.0推出WCF之前使用的WebService,有的应用有使用Session保持一些信息,在不 ...

  8. HtmlAgilityPack + Fizzler

    HtmlAgilityPack + Fizzler 这两天在做个爬虫, 一次任务要下载3万多个页面, 然后从这3万多个页面提取数据. 以前写过两年的类似的东西, 基本都是写正则表达式, 速度快, 就是 ...

  9. CSS3可按进度变色的进度条

    原文:CSS3可按进度变色的进度条 今天是周末,看到一款利用CSS3实现的进度条应用,觉得非常棒,就将它分享给大家,并且将这款CSS3进度条的实现过程大致整理了一下,实现的关键是根据当前的进度需要能改 ...

  10. android项目总体界面架构(可直接复用)

    文章解读.效果图.源代码下载链接 http://blog.csdn.net/gao_chun/article/details/37903673