标签 ui 下的文章

UI9_UITableView---

//
// RootViewController.m
// UI9_UITableView
//
// Created by YIem on 15/12/17.
// Copyright (c) 2015年 www.yiem.net YIem博客. All rights reserved.
//

import "RootViewController.h"

@interface RootViewController ()<UITableViewDataSource,UITableViewDelegate>

@end

@implementation RootViewController

  • (void)viewDidLoad {

    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    
    
    ///************UITableView 表视图*************////
    UITableView *tableView = [[UITableView alloc]initWithFrame:self.view.bounds style:UITableViewStylePlain];
    tableView.backgroundColor = [UIColor yellowColor];
    [self.view addSubview:tableView];
    [tableView release];
    
    
    ////// 1. 设置代理人
    tableView.delegate = self;
    tableView.dataSource = self;
    
    // 设置
    // 行高
    tableView.rowHeight = 100;
    // 分割线样式
    tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
    // 分割线颜色
    tableView.separatorColor = [UIColor redColor];

    }

warning 实现tableView时 必须实现的两个协议方法

// 1.每个分区中的cell行数

  • (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
    {
    // 前没有设置分区时 默认分区数为1
    return 10;
    }

// 2.设置每个cell内容
// 参数1: 触发方法的tableView
// 参数2: cell的位置信息

  • (UITableViewCell )tableView:(UITableView )tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {

    // indexPath 用于定位每个cell
    // 包含: roe(行号) / section(分区hao)

if 0

// 创建cell
UITableViewCell *cell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:nil] autorelease];
// 设置
// 标题
cell.textLabel.text = @"姓名";
// 副标题
cell.detailTextLabel.text = @"phoneNumber";
// 图片
cell.imageView.image = [UIImage imageNamed:@"1"];
// 辅助视图

// cell.accessoryType = UITableViewCellAccessoryDetailButton;// 感叹号
// cell.accessoryType = UITableViewCellAccessoryCheckmark;// 对号
// cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;// 感叹号,对号

cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
// accessoryView 添加视图

endif


// cell的重用机制
// 1.从重用池中获取cell
// 参数: 重用机制 (识别不同重用池)
UITableViewCell  *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
// 2.判断cell是否存在
// !cell 等同 cell == nil
if (!cell) {
    // 3.创建cell
    // 参数1;cell的样式
    // 参数2: cell的重用标识(区分进入哪个重用池)
    cell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"] autorelease];

warning 判断中 只写cell创建 不要写赋值

}
// 4.设置cell
cell.textLabel.text = @"标题";
cell.detailTextLabel.text = @"副标题";
cell.imageView.image = [UIImage imageNamed:@"1"];
cell.accessoryType = UITableViewCellAccessoryCheckmark;



// 辅助视图
// 图片

// UIImageView *img = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 30, 30)];
// img.image = [[UIImage imageNamed:@"1"] autorelease];
// cell.accessoryView = img;


// 开关 switch
cell.accessoryView = [[UISwitch alloc]initWithFrame:CGRectMake(0, 0, 30, 30)];


// 将设置好的cell对象返回
return cell;

}

  • (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

2015-15-16--UI8_练习--传值练习

//
// AppDelegate.h
// UI8_练习
//
// Created by YIem on 15/12/16.
// Copyright (c) 2015年 www.yiem.net YIem博客. All rights reserved.
//

import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (retain, nonatomic) UIWindow *window;

@end







- 阅读剩余部分 -

2015-12-16-UI8_Block-----block 快语法(闭包)

//
// AppDelegate.h
// UI8_Block
//
// Created by YIem on 15/12/16.
// Copyright (c) 2015年 www.yiem.net YIem博客. All rights reserved.
//

import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (retain, nonatomic) UIWindow *window;

@end


//
// AppDelegate.m
// UI8_Block
//
// Created by YIem on 15/12/16.
// Copyright (c) 2015年 www.yiem.net YIem博客. All rights reserved.
//

import "AppDelegate.h"

import "RootViewController.h"

@interface AppDelegate ()

@end

@implementation AppDelegate

-(void)dealloc
{

[_window release];

[super dealloc];
}

  • (BOOL)application:(UIApplication )application didFinishLaunchingWithOptions:(NSDictionary )launchOptions {
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];

    RootViewController *rotVC = [[RootViewController alloc]init];
    UINavigationController *navi = [[UINavigationController alloc]initWithRootViewController:rotVC];
    self.window.rootViewController = navi;

    [rotVC release];
    [navi release];

    / Block 快语法*/

    [_window release];
    return YES;
    }

  • (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
    }
  • (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
    }
  • (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
    }
  • (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
    }
  • (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
    }

@end




































- 阅读剩余部分 -

2015-15-16- UI8_协议传值

//
// AppDelegate.h
// UI8_协议传值
//
// Created by YIem on 15/12/16.
// Copyright (c) 2015年 www.yiem.net YIem博客. All rights reserved.
//

import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (retain, nonatomic) UIWindow *window;

@end







- 阅读剩余部分 -

2015-12-16 UI7作业1--创建三个控制器

//
**创建三个控制器 要求 :
1.命名 First ~ Third。 2.分别设置背景颜⾊色红、灰、蓝。 3.如⽰示例完成⾃自定义导航栏。**

//
// AppDelegate.h
// UI7_作业
//
// Created by YIem on 15/12/15.
// Copyright (c) 2015年 www.yiem.net YIem博客. All rights reserved.
//

import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (retain, nonatomic) UIWindow *window;

@end









- 阅读剩余部分 -

2015-12-16--UI7_页面跳转 - 传值

//
// AppDelegate.h
// UI7_页面跳转
//
// Created by YIem on 15/12/15.
// Copyright (c) 2015年 www.yiem.net YIem博客. All rights reserved.
//

import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (retain, nonatomic) UIWindow *window;

@end







- 阅读剩余部分 -

2015-12-16 UI7_UINavigationController

//
// RootViewController.m
// UI7_UINavigationController
//
// 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];
    
    //********< 导航栏设置>************//
    //< 半透明效果 >****
    self.navigationController.navigationBar.translucent = YES;
    // 半透明下 坐标原点在屏幕左上角   默认半透明
    // 不透明下 坐标原点在导航栏左下角
    
    UIView *aview = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];
    aview.backgroundColor = [UIColor yellowColor];
    [self.view addSubview:aview];
    [aview release];
    //**< 显示/隐藏> ****
    self.navigationController.navigationBarHidden = NO;
    //**< 导航栏背景颜色>****
    self.navigationController.navigationBar.backgroundColor = [UIColor grayColor];
    //**< 导航栏颜色>****
    // 状态栏(statuBar)会跟随导航栏一起变色

    // self.navigationController.navigationBar.barTintColor = [UIColor cyanColor];

    //**< 导航栏样式 >****两种方式

    // self.navigationController.navigationBar.barStyle = UIBarStyleBlack;

    self.navigationController.navigationBar.barStyle = UIBarStyleDefault;
    
    //*****<导航标题>***

    // self.title = @"标题";

// self.navigationItem.title = @"标题";







- 阅读剩余部分 -

2015-12-15 iOS UI 实现 通讯录滚动

//
// RootViewController.miOS Simulator Screen Shot 2015年12月15日 下午12.46.17.png
// UI6_作业1
//
// Created by YIem on 15/12/14.
// Copyright (c) 2015年 www.yiem.net YIem博客. All rights reserved.
//

import "RootViewController.h"

import "LTView.h"

import "CellViewTableViewCell.h"

@interface RootViewController ()<UIScrollViewDelegate>

@end

@implementation RootViewController

  • (void)viewDidLoad {

    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    
    // Phone
    // 滚
    UIScrollView *phone = [[UIScrollView alloc]initWithFrame:self.view.frame];
    phone.backgroundColor = [UIColor grayColor];
    [self.view addSubview:phone];
    
    phone.contentSize = CGSizeMake(0, self.view.frame.size.height * 1.5);
    
    
    [phone release];
    
    //
    LTView *s1 = [[LTView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 110)];
    s1.backgroundColor = [UIColor whiteColor];
    s1.label1.text = @"卞一";
    s1.label2.text = @"1879414****";
    s1.label3.text = @"";
    s1.img.image = [UIImage imageNamed:@"900738"];
    // 添加到phone视图/// 在phone视图滚动
    [phone addSubview:s1];
    






- 阅读剩余部分 -

2015-12-15-iOS UI 实现通讯记录

iOS Simulator Screen Shot 2015年12月15日 下午12.45.50.png

//
// RootViewController.m
// Phone2
//
// Created by YIem on 15/12/12.
// Copyright (c) 2015年 www.yiem.net YIem博客. All rights reserved.
//

import "RootViewController.h"

import "TLView.h"

@interface RootViewController ()

@end

@implementation RootViewController

  • (void)viewDidLoad {

    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    //
    UISegmentedControl *seg = [[UISegmentedControl alloc]initWithItems:@[@"AII", @"Missed"]];
    seg.frame = CGRectMake(100, 25, 150, 40);
    seg.center = CGPointMake(self.view.center.x, 50);
    [self.view addSubview:seg];
    seg.backgroundColor = [UIColor whiteColor];
    seg.selectedSegmentIndex = 0;
    [seg release];
    //
    UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
    button.frame = CGRectMake(0, 590,self.view.frame.size.width, 70);
    [self.view addSubview:button];
    [button setBackgroundImage:[UIImage imageNamed:@"12.jpg"] forState:UIControlStateNormal];
    button.self.layer.cornerRadius = 35;
    
    






- 阅读剩余部分 -

2015-12-15-iOS UI 实现QQ聊天界面

//
iOS Simulator Screen Shot 2015年12月15日 下午12.44.43.png
// RootViewController.m
// Phone
//
// Created by YIem on 15/12/12.
// Copyright (c) 2015年 www.yiem.net YIem博客. All rights reserved.
//

import "RootViewController.h"

import "LTView.h"

import "PhoneViewController.h"

@interface RootViewController ()

@end

@implementation RootViewController

  • (void)viewDidLoad {

    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = [UIColor whiteColor];
    // 背景框
    UISegmentedControl *seg = [[UISegmentedControl alloc]initWithItems:@[@"消息", @"电话"]];
    seg.frame = CGRectMake(100, 25, 150, 40);

    // seg.self.layer.cornerRadius = 30;

    seg.center = CGPointMake(self.view.center.x, 50);
    seg.selectedSegmentIndex = 0;
    seg.backgroundColor = [UIColor whiteColor];
    [seg addTarget:self action:@selector(segAction:) forControlEvents:UIControlEventValueChanged];
    [self.view addSubview:seg];
    [seg release];
    
    // 调用 搜索
    [self sousuo];
    // 调用左上角头像
    [self toxi];
    // 调用右上角
    [self youtu];

    //








- 阅读剩余部分 -

2015-12-15- iOS UI 实现TOM猫

iOS Simulator Screen Shot 2015年12月15日 下午12.43.27.png
//
// RootViewController.m
// Tom
//
// Created by YIem on 15/12/11.
// Copyright (c) 2015年 www.yiem.net YIem博客. All rights reserved.
//

import "RootViewController.h"

@interface RootViewController ()
@property (nonatomic, retain)UIImageView *imgTom1;
@end

@implementation RootViewController

  • (void)viewDidLoad {

    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    
    
    self.imgTom1 = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width , self.view.frame.size.height)];
    self.imgTom1.backgroundColor = [UIColor clearColor];
    [self.view addSubview:self.imgTom1];
    [_imgTom1 release];
    NSString *grassPath =  [[NSBundle mainBundle] pathForResource:@"angry_0" ofType:@"jpg"];
    self.imgTom1.image = [UIImage imageWithContentsOfFile:grassPath];
    
    // Tom1
    
    

//[self TOM1];
// [self TOMtu1];


// 按钮
[self an1];
[self an2];
[self an3];
[self an1_1];
[self an2_1];
[self an3_1];
// 隐藏按钮
[self anto];
[self anzhon];
[self anxiao];
[self anfootLeft];
[self anfootRight];

}
// 图标按钮123456

  • (void)an1
    {

    UIButton *buttomTom1 =[UIButton buttonWithType:UIButtonTypeSystem];
    buttomTom1.frame = CGRectMake(20, 400, 50, 50);
    
    [buttomTom1 setBackgroundImage:[UIImage imageNamed:@"eat.png"] forState:UIControlStateNormal];
    [buttomTom1 addTarget:self action:@selector(TOMtu1) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:buttomTom1];
    [buttomTom1 release];
    
    

}













- 阅读剩余部分 -

2015-12-15- UI6_UIScrollView

//
// RootViewController.m
// UI6_UIScrollView
//
// Created by YIem on 15/12/14.
// Copyright (c) 2015年 www.yiem.net YIem博客. All rights reserved.
//

import "RootViewController.h"

@interface RootViewController () <UIScrollViewDelegate>// 协议

@end

@implementation RootViewController

  • (void)viewDidLoad {

    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    ////********* UIScrollView 滚动视图*************///
    
    //    UIScrollView   是所有滚动视图的基类
    // 功能 : 1.滚动 2.播放

if 0

// 1.创建
UIScrollView *sv = [[UIScrollView alloc]initWithFrame:CGRectMake(100, 100, 200, 200)];
// 2.设置
sv.backgroundColor = [UIColor yellowColor];
// 3.添加父视图
[self.view addSubview:sv];
// 4.内存
[sv release];
// 滚动的条件: 实际内容大小 > 滚动视图自身的frame
////*******<  contentSize  内容大小 >*******////
sv.contentSize = CGSizeMake(300, 300);
/// 只允许左右滚动

// sv.contentSize = CGSizeMake(300, 0);

// 只允许上下ai

// sv.contentSize = CGSizeMake(0, 300);

endif







- 阅读剩余部分 -

2015-12-15- UI5_UIControl-

//
// RootViewController.m
// UI5_UIControl
//
// Created by YIem on 15/12/11.
// Copyright (c) 2015年 www.yiem.net YIem博客. All rights reserved.
//

import "RootViewController.h"

// UI枚举实现 练习 红黄蓝 + Switch 循环
typedef NS_ENUM(NSUInteger, hhl) {

RedColor,
YellColor,
BlueColor,

};

@interface RootViewController ()

@end

@implementation RootViewController

  • (void)viewDidLoad {

    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = [UIColor whiteColor];
    

if 0

///******UIcontrol******////

/***<    SegmentedConteol 分段控制器>*/
UISegmentedControl *seg = [[UISegmentedControl alloc]initWithItems:@[@"王者", @"大师", @"钻石", @"白金", @"黄金", @"白银", @"青铜"]];
// 设置frame
seg.frame = CGRectMake(50, 100, 300, 50);

// 添加父视图
[self.view addSubview:seg];
[seg release];

// 背景颜色
seg.backgroundColor = [UIColor yellowColor];

// 边框颜色
seg.tintColor = [UIColor blackColor];

// 分段索引  // 初始默认选中为第几位
seg.selectedSegmentIndex = 2;

// 添加一个新的分段
[seg insertSegmentWithTitle:@"卞一" atIndex:0 animated:YES];

// 添加点击事件
// valueChange 值变化时 触发方法
[seg addTarget:self action:@selector(segAction:) forControlEvents:UIControlEventValueChanged];

endif








- 阅读剩余部分 -