2015-12-15 iOS UI 实现 通讯录滚动
//
// RootViewController.m
// 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];
[s1 release];
//
LTView *s2 = [[LTView alloc]initWithFrame:CGRectMake(0, 110, self.view.frame.size.width, 110)];
s2.backgroundColor = [UIColor whiteColor];
s2.label1.text = @"YIem";
s2.label2.text = @"1888888888";
s2.img.image = [UIImage imageNamed:@"900738"];
[phone addSubview:s2];
[s2 release];
//
LTView *s3 = [[LTView alloc]initWithFrame:CGRectMake(0, 220, self.view.frame.size.width, 110)];
s3.backgroundColor = [UIColor whiteColor];
s3.label1.text = @"吴晋儒";
s3.label2.text = @"12131313131";
s3.img.image = [UIImage imageNamed:@"900738"];
[phone addSubview:s3];
[s3 release];
//
LTView *s4 = [[LTView alloc]initWithFrame:CGRectMake(0, 330, self.view.frame.size.width, 110)];
s4.backgroundColor = [UIColor whiteColor];
s4.label1.text = @"吴壹";
s4.label2.text = @"645621364";
s4.img.image = [UIImage imageNamed:@"900738"];
[phone addSubview:s4];
[s4 release];
//
LTView *s5 = [[LTView alloc]initWithFrame:CGRectMake(0, 440, self.view.frame.size.width, 110)];
s5.backgroundColor = [UIColor whiteColor];
s5.label1.text = @"第五吴";
s5.label2.text = @"46989765489";
s5.img.image = [UIImage imageNamed:@"900738"];
[phone addSubview:s5];
[s5 release];
//
LTView *s6 = [[LTView alloc]initWithFrame:CGRectMake(0, 550, self.view.frame.size.width, 110)];
s6.backgroundColor = [UIColor whiteColor];
s6.label1.text = @"口天吴";
s6.label2.text = @"979879865";
s6.img.image = [UIImage imageNamed:@"900738"];
[phone addSubview:s6];
[s6 release];
//
LTView *s7 = [[LTView alloc]initWithFrame:CGRectMake(0, 660, self.view.frame.size.width, 110)];
s7.backgroundColor = [UIColor whiteColor];
s7.label1.text = @"萱草";
s7.label2.text = @"97561498456";
s7.img.image = [UIImage imageNamed:@"900738"];
[phone addSubview:s7];
[s7 release];
//
LTView *s8 = [[LTView alloc]initWithFrame:CGRectMake(0, 770, self.view.frame.size.width, 110)];
s8.backgroundColor = [UIColor whiteColor];
s8.label1.text = @"吴雨熙";
s8.label2.text = @"656656464";
s8.img.image = [UIImage imageNamed:@"900738"];
[phone addSubview:s8];
[s8 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
//
// LTView.h
// UI6_作业1
//
// Created by YIem on 15/12/14.
// Copyright (c) 2015年 www.yiem.net YIem博客. All rights reserved.
//
import <UIKit/UIKit.h>
@interface LTView : UIView
@property (nonatomic, retain)UILabel *label1;
@property (nonatomic, retain)UILabel *label2;
@property (nonatomic, retain)UILabel *label3;
@property (nonatomic, retain)UIImageView *img;
@end
//
// LTView.m
// UI6_作业1
//
// Created by YIem on 15/12/14.
// Copyright (c) 2015年 www.yiem.net YIem博客. All rights reserved.
//
import "LTView.h"
@implementation LTView
- (void)dealloc
{
[_label1 release];
[_label2 release];
[_label3 release];
[_img release];
[super dealloc];
} (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {[self creat];
}
return self;
}- (void)creat
{
// tu
self.img = [[UIImageView alloc]initWithFrame:CGRectMake(20, 20, 80, 80)];
self.img.layer.cornerRadius =15;
self.img.layer.borderWidth = 1.0;
self.img.clipsToBounds = YES;
[self addSubview:self.img];
[self.img release];
// xing
self.label1 = [[UILabel alloc]initWithFrame:CGRectMake(110, 20, 200, 40)];
self.label1.font = [UIFont systemFontOfSize:30];
[self addSubview:self.label1];
self.label1.textAlignment = NSTextAlignmentCenter;self.label1.layer.borderWidth = 1.0;
self.label1.layer.cornerRadius = 5;
// self.label1.clipsToBounds = YES;
[_label1 release];
// phone
self.label2 = [[UILabel alloc]initWithFrame:CGRectMake(110, 70, 200, 30)];
[self addSubview:self.label2];
self.label2.textAlignment = NSTextAlignmentCenter;
self.label2.layer.borderWidth = 1.0;
self.label2.layer.cornerRadius = 5;
[_label2 release];
// [self.label2 release];
self.label3 = [[UILabel alloc]initWithFrame:CGRectMake(0, 105, 330, 1)];
self.label3.center = CGPointMake(self.center.x, 105);
[self addSubview:self.label3];
self.label3.backgroundColor = [UIColor blackColor];
[_label3 release];
}
//
//myLabel.layer.borderColor = [UIColor blackColor].CGColor;
//
//myLabel.layer.borderWidth = 2.0;
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
(void)drawRect:(CGRect)rect {
// Drawing code
}
*/
@end
当前页面是本站的「Google AMP」版。查看和发表评论请点击:完整版 »