2015-12-16 - UI7-----练习
//
// RootViewController.m
// UI7_练习
//
// Created by YIem on 15/12/15.
// Copyright (c) 2015年 www.yiem.net YIem博客. All rights reserved.
//
import "RootViewController.h"
@interface RootViewController ()
@end
@implementation RootViewController
(void)viewDidLoad {
[super viewDidLoad]; // Do any additional setup after loading the view. self.view.backgroundColor = [UIColor redColor]; /// 要求 // 1.创建工程 设置导航为根视图 rootVC为导航的根视图 // 2.rootVC中创建一个和屏幕一样大的scrollView 让scrollView可以滚动 // 3.新建一个UIView对象 添加在scrollView上 frame为(0, 0, 100, 100)
// UIView *aview = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];
// aview.backgroundColor = [UIColor yellowColor];
// [self.view addSubview:aview];
// [aview release];
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 375 / 2, 667)];
scrollView.backgroundColor = [UIColor yellowColor];
scrollView.contentSize = CGSizeMake(1000, 1000);
[self.view addSubview:scrollView];
[scrollView release];
//
UIView *aView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
aView.backgroundColor = [UIColor cyanColor];
[scrollView addSubview:aView];
[aView release];
// 多个页面
UIScrollView *scrollView1 = [[UIScrollView alloc] initWithFrame:CGRectMake(375 / 2, 0, 375 / 2, 667)];
scrollView1.backgroundColor = [UIColor redColor];
scrollView1.contentSize = CGSizeMake(self.view.frame.size.width * 4, 0);
[self.view addSubview:scrollView1];
[scrollView1 release];
//
UIView *aView1 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
aView1.backgroundColor = [UIColor cyanColor];
[scrollView1 addSubview:aView1];
[aView1 release];
///*******<滑动视图自适应边界预留值>***
// VC 中的第一个滑动视图会自动添加一个上边距
self.automaticallyAdjustsScrollViewInsets = YES;
////****< >
// 导航栏不透明时 坐标系统一没问题
self.navigationController.navigationBar.translucent = NO;
// 标题
UISegmentedControl *seg = [[UISegmentedControl alloc]initWithItems:@[@"电话", @"聊天"]];
seg.frame = CGRectMake(100, 100, 100, 40);
seg.selectedSegmentIndex = 0;
self.navigationItem.titleView = seg;
[seg release];
}
(void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated.
}
/*
pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller.
}
*/
@end