Commit 965ec28b authored by admin's avatar admin

修改主页布局

parent c285d9ac
This diff is collapsed.
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
......@@ -6,12 +6,12 @@
},
{
"idiom" : "universal",
"filename" : "task_online@2x.png",
"filename" : "back_btn@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "task_online@3x.png",
"filename" : "back_btn@3x.png",
"scale" : "3x"
}
],
......
......@@ -6,12 +6,12 @@
},
{
"idiom" : "universal",
"filename" : "praise_image@2x.png",
"filename" : "default_pic@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "praise_image@3x.png",
"filename" : "default_pic@3x.png",
"scale" : "3x"
}
],
......
......@@ -6,12 +6,12 @@
},
{
"idiom" : "universal",
"filename" : "excellent_case@2x.png",
"filename" : "function_check@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "excellent_case@3x.png",
"filename" : "function_check@3x.png",
"scale" : "3x"
}
],
......
......@@ -6,12 +6,12 @@
},
{
"idiom" : "universal",
"filename" : "praise_standard@2x.png",
"filename" : "function_uncheck@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "praise_standard@3x.png",
"filename" : "function_uncheck@3x.png",
"scale" : "3x"
}
],
......
......@@ -6,12 +6,12 @@
},
{
"idiom" : "universal",
"filename" : "praise_report@2x.png",
"filename" : "home_title@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "praise_report@3x.png",
"filename" : "home_title@3x.png",
"scale" : "3x"
}
],
......
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "question_problem@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "question_problem@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "search@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "search@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "task_00@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "task_00@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "task_01@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "task_01@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "task_02@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "task_02@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "task_03@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "task_03@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "task_04@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "task_04@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "task_05@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "task_05@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
......@@ -48,19 +48,27 @@
{
// 跳转到tabbarController
HomeViewController *home = [[HomeViewController alloc]init];
UINavigationController *homeNav = [self setUpOneChildViewController:home title:@"首页" imageName:@"home_unchecked" selImageName:@"home_checked"];
HomeViewController *home = (HomeViewController *)[self setUpOneChildViewController:[[HomeViewController alloc] init] title:@"首页" imageName:@"home_unchecked" selImageName:@"home_checked"];
UINavigationController *homeNav = [[UINavigationController alloc] initWithRootViewController:home];
[homeNav.navigationBar setBarTintColor:kNavigationBarColor];
[homeNav.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],NSForegroundColorAttributeName,nil]];
AnnounceViewController *announce = [[AnnounceViewController alloc] init];
UINavigationController *announceNav = [self setUpOneChildViewController:announce title:@"公告" imageName:@"notice_unchecked" selImageName:@"notice_checked"];
AnnounceViewController *announce = (AnnounceViewController *)[self setUpOneChildViewController:[[AnnounceViewController alloc] init] title:@"公告" imageName:@"notice_unchecked" selImageName:@"notice_checked"];
// 添加nav
UINavigationController *announceNav = [[UINavigationController alloc] initWithRootViewController:announce];
[announceNav.navigationBar setBarTintColor:kNavigationBarColor];
[announceNav.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],NSForegroundColorAttributeName,nil]];
ChartViewController *chart = [[ChartViewController alloc] init];
UINavigationController *chartNav = [self setUpOneChildViewController:chart title:@"报表查询" imageName:@"report_unchecked" selImageName:@"report_checked"];
ChartViewController *chart = (ChartViewController *)[self setUpOneChildViewController:[[ChartViewController alloc] init] title:@"报表查询" imageName:@"report_unchecked" selImageName:@"report_checked"];
UINavigationController *chartNav = [[UINavigationController alloc] initWithRootViewController:chart];
[chartNav.navigationBar setBarTintColor:kNavigationBarColor];
[chartNav.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],NSForegroundColorAttributeName,nil]];
MineViewController *mine = [[MineViewController alloc] init];
UINavigationController *mineNav = [self setUpOneChildViewController:mine title:@"我的" imageName:@"aboutme_unchecked" selImageName:@"aboutme_checke"];
MineViewController *mine = (MineViewController *)[self setUpOneChildViewController:[[MineViewController alloc] init] title:@"我的" imageName:@"aboutme_unchecked" selImageName:@"aboutme_checke"];
UINavigationController *mineNav = [[UINavigationController alloc] initWithRootViewController:mine];
[mineNav.navigationBar setBarTintColor:kNavigationBarColor];
[mineNav.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],NSForegroundColorAttributeName,nil]];
[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
kNavigationBarColor, NSForegroundColorAttributeName,
......@@ -72,7 +80,7 @@
// 添加一个控制器的属性
- (UINavigationController *)setUpOneChildViewController:(UIViewController *)vc title:(NSString *)title imageName:(NSString *)imageName selImageName:(NSString *)selImageName
- (UIViewController *)setUpOneChildViewController:(UIViewController *)vc title:(NSString *)title imageName:(NSString *)imageName selImageName:(NSString *)selImageName
{
// 添加TabBar按钮的图片文字
vc.title = title;
......@@ -81,11 +89,9 @@
selImage = [selImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
vc.tabBarItem.selectedImage = selImage;
// 添加nav
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];
[nav.navigationBar setBarTintColor:kNavigationBarColor];
[nav.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],NSForegroundColorAttributeName,nil]];
return nav;
return vc;
}
#pragma mark - UITabBarController Delegate
......
//
// NewAnnounceCell.h
// PictureStoryViewController.h
// redstar
//
// Created by admin on 15/10/30.
// Created by admin on 15/11/16.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface NewAnnounceCell : UITableViewCell
@property (nonatomic, strong) UILabel *announceLabel; // 公告
@property (nonatomic, strong) UILabel *pointLabel; // 点点
@interface PictureStoryViewController : UIViewController
@end
//
// PictureStoryViewController.m
// redstar
//
// Created by admin on 15/11/16.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import "PictureStoryViewController.h"
@interface PictureStoryViewController ()
@end
@implementation PictureStoryViewController
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
self.navigationController.navigationBar.hidden = NO;
}
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
[self setupNav];
}
#pragma mark - Private Methods
- (void)setupNav
{
UILabel *customLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 40, 30)];
[customLab setTextColor:[UIColor whiteColor]];
[customLab setText:@"图说口碑"];
customLab.font = [UIFont boldSystemFontOfSize:19];
self.navigationItem.titleView = customLab;
UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
backBtn.frame = CGRectMake(0, 0, 30, 44);
[backBtn setImage:[UIImage imageNamed:@"back_btn"] forState:UIControlStateNormal];
[backBtn addTarget:self action:@selector(doBack:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithCustomView:backBtn];
self.navigationItem.leftBarButtonItem = backItem;
}
-(void)doBack:(id)sender
{
[self.navigationController popViewControllerAnimated:YES];
}
- (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
......@@ -26,7 +26,7 @@
#pragma mark - Private Methods
- (void)setup
{
self.titleImageView.image = [UIImage imageNamed:@""];
self.titleImageView.image = [UIImage imageNamed:@"default_pic"];
self.titleLabel.textColor = kPictureCellTitleColor;
self.hotLabel.font = [UIFont boldSystemFontOfSize:12.0];
self.detailsLabel.textColor = kPictureCellDetailsColor;
......
......@@ -10,6 +10,8 @@
#import "MenuButton.h"
#import "PictureTableCell.h"
#import "PictureStoryViewController.h"
#define kPictureTableViewCell @"pictureTabelViewCell"
@interface PictureViewController () <UITableViewDelegate, UITableViewDataSource>
......@@ -54,6 +56,20 @@
rightButton.titleLabel.font = [UIFont systemFontOfSize:15];
UIBarButtonItem *rightButtonItem = [[UIBarButtonItem alloc] initWithCustomView:rightButton];
self.navigationItem.rightBarButtonItem = rightButtonItem;
UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
backBtn.frame = CGRectMake(0, 0, 30, 44);
[backBtn setImage:[UIImage imageNamed:@"back_btn"] forState:UIControlStateNormal];
[backBtn addTarget:self action:@selector(doBack:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithCustomView:backBtn];
self.navigationItem.leftBarButtonItem = backItem;
}
-(void)doBack:(id)sender
{
[self.navigationController dismissViewControllerAnimated:YES completion:nil];
}
- (void)setupTableView
......@@ -104,6 +120,12 @@
return 0;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
PictureStoryViewController *storyVC = [[PictureStoryViewController alloc] init];
[self.navigationController pushViewController:storyVC animated:YES];
}
// 自定义section
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
......
......@@ -50,6 +50,8 @@
{
[super viewWillAppear:animated];
self.navigationController.navigationBar.hidden = NO;
self.tabBarController.tabBar.hidden = YES;
}
......
......@@ -37,6 +37,6 @@
@property (nonatomic, strong) NSString *submitTime;//
@property (nonatomic, strong) NSString *type;//问题处理分类
@property (nonatomic, strong) NSString *version;//
@property (nonatomic, strong) NSString *hotspot; // 热点问题
@property (nonatomic, strong) NSString *likeCount; //
@end
......@@ -118,7 +118,6 @@
- (void)setupTableView
{
[self.tableView registerClass:[QuestionListTableCell class] forCellReuseIdentifier:kQuestionListCell];
self.searchBar.backgroundColor = kSectionBackGroundColor;
}
......@@ -138,8 +137,22 @@
rightButton.titleLabel.font = [UIFont systemFontOfSize:15];
UIBarButtonItem *rightButtonItem = [[UIBarButtonItem alloc] initWithCustomView:rightButton];
self.navigationItem.rightBarButtonItem = rightButtonItem;
UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
backBtn.frame = CGRectMake(0, 0, 30, 44);
[backBtn setImage:[UIImage imageNamed:@"back_btn"] forState:UIControlStateNormal];
[backBtn addTarget:self action:@selector(doBack:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithCustomView:backBtn];
self.navigationItem.leftBarButtonItem = backItem;
}
- (void)doBack:(id)sender
{
[self.navigationController dismissViewControllerAnimated:YES completion:nil];
}
- (void)addClick:(UIButton *)sender
{
AddQuestionViewController *addQuestionVC = [[AddQuestionViewController alloc] init];
......
......@@ -30,6 +30,13 @@
@implementation InspectTaskViewController
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
self.navigationController.navigationBar.hidden = NO;
}
- (void)viewDidLoad {
[super viewDidLoad];
......
......@@ -28,6 +28,13 @@
@end
@implementation RankDetailViewController
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
self.navigationController.navigationBar.hidden = NO;
self.tabBarController.tabBar.hidden = YES;
}
- (void)viewDidLoad
{
......
......@@ -34,6 +34,16 @@
customLab.font = [UIFont boldSystemFontOfSize:19];
self.navigationItem.titleView = customLab;
UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
backBtn.frame = CGRectMake(0, 0, 30, 44);
[backBtn setImage:[UIImage imageNamed:@"back_btn"] forState:UIControlStateNormal];
[backBtn addTarget:self action:@selector(doBack:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithCustomView:backBtn];
self.navigationItem.leftBarButtonItem = backItem;
if([[[UIDevice currentDevice]systemVersion]floatValue] >= 7.0) {
self.edgesForExtendedLayout = UIRectEdgeNone;
}
......@@ -79,6 +89,11 @@
}];
}
-(void)doBack:(id)sender
{
[self.navigationController dismissViewControllerAnimated:YES completion:nil];
}
- (void)addTableViews
{
[self.tableView registerClass:[RankingListCell class] forCellReuseIdentifier:kRankingCell];
......
......@@ -19,8 +19,7 @@
self.titleLabel.font = [UIFont systemFontOfSize:15];
[self setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[self setTitleColor:[UIColor orangeColor] forState:UIControlStateSelected];
self.layer.borderWidth = 0.5;
self.layer.borderColor = kLineCGColor;
}
return self;
}
......@@ -31,11 +30,10 @@
CGFloat btnW = self.width;
CGFloat btnH = self.height;
CGFloat imageH = btnH * 0.7;
self.imageView.frame = CGRectMake(0, 7, btnW, imageH);
self.imageView.frame = CGRectMake((btnW - 45) / 2 , 13, 45, 45);
CGFloat titleH = btnH - imageH;
CGFloat titleY = imageH - 5;
CGFloat titleH = btnH - 55;
CGFloat titleY = 61;
self.titleLabel.frame = CGRectMake(0, titleY, btnW, titleH);
// // 设置badgeView尺寸
......
//
// HomeFunctionCell.h
// redstar
//
// Created by admin on 15/10/26.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "HomeCellItem.h"
@interface HomeFunctionCell : UITableViewCell
@property (nonatomic, strong) HomeCellItem *onLineSamplingBtn; // 在线抽查按钮
@property (nonatomic, strong) HomeCellItem *wordOfMouthBtn; // 口碑按钮
@property (nonatomic, strong) HomeCellItem *standardBtn; // 口碑标准按钮
@property (nonatomic, strong) HomeCellItem *pictureBtn; // 图说口碑按钮
@property (nonatomic, strong) HomeCellItem *questionBtn; // 问题与知识按钮
@property (nonatomic, strong) HomeCellItem *caseBtn; // 优秀案例按钮
@end
This diff is collapsed.
//
// HomeTitleTableCell.h
// redstar
//
// Created by admin on 15/11/16.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface HomeTitleTableCell : UITableViewCell
@end
//
// HomeTitleTableCell.m
// redstar
//
// Created by admin on 15/11/16.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import "HomeTitleTableCell.h"
@implementation HomeTitleTableCell
#pragma mark - System Methods
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
[self setup];
}
return self;
}
- (void)setup
{
// 商场
UILabel *shoppingLabel = [[UILabel alloc] init];
shoppingLabel.text = @"商场名称";
shoppingLabel.textAlignment = NSTextAlignmentCenter;
shoppingLabel.textColor = kRankHeadTitleTextColor;
shoppingLabel.font = [UIFont systemFontOfSize:17.0];
shoppingLabel.translatesAutoresizingMaskIntoConstraints = NO;
[self.contentView addSubview:shoppingLabel];
// 总分
UILabel *scoreLabel = [[UILabel alloc] init];
scoreLabel.text = @"总分";
scoreLabel.textAlignment = NSTextAlignmentCenter;
scoreLabel.textColor = kRankHeadTitleTextColor;
scoreLabel.font = [UIFont systemFontOfSize:17.0];
scoreLabel.translatesAutoresizingMaskIntoConstraints = NO;
[self.contentView addSubview:scoreLabel];
// 排名
UILabel *gradeLabel = [[UILabel alloc] init];
gradeLabel.text = @"排名";
gradeLabel.textAlignment = NSTextAlignmentCenter;
gradeLabel.textColor = kRankHeadTitleTextColor;
gradeLabel.font = [UIFont systemFontOfSize:17.0];
gradeLabel.translatesAutoresizingMaskIntoConstraints = NO;
[self.contentView addSubview:gradeLabel];
//
NSLayoutConstraint *shoppingTop = [NSLayoutConstraint constraintWithItem:shoppingLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:5];
[self.contentView addConstraint:shoppingTop];
NSLayoutConstraint *shoppingLeft = [NSLayoutConstraint constraintWithItem:shoppingLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
[self.contentView addConstraint:shoppingLeft];
NSLayoutConstraint *shoppingRight = [NSLayoutConstraint constraintWithItem:shoppingLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:scoreLabel attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
[self.contentView addConstraint:shoppingRight];
NSLayoutConstraint *shoppingBottom = [NSLayoutConstraint constraintWithItem:shoppingLabel attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[self.contentView addConstraint:shoppingBottom];
NSLayoutConstraint *shoppingWidth = [NSLayoutConstraint constraintWithItem:shoppingLabel attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:scoreLabel attribute:NSLayoutAttributeWidth multiplier:1.2 constant:0];
[self.contentView addConstraint:shoppingWidth];
//
NSLayoutConstraint *scoreTop = [NSLayoutConstraint constraintWithItem:scoreLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:5];
[self.contentView addConstraint:scoreTop];
NSLayoutConstraint *scoreRight = [NSLayoutConstraint constraintWithItem:scoreLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:gradeLabel attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
[self.contentView addConstraint:scoreRight];
NSLayoutConstraint *scoreWidth = [NSLayoutConstraint constraintWithItem:scoreLabel attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:gradeLabel attribute:NSLayoutAttributeWidth multiplier:1.0 constant:0];
[self.contentView addConstraint:scoreWidth];
NSLayoutConstraint *scoreBottom = [NSLayoutConstraint constraintWithItem:scoreLabel attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[self.contentView addConstraint:scoreBottom];
//
NSLayoutConstraint *gradeTop = [NSLayoutConstraint constraintWithItem:gradeLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:5];
[self.contentView addConstraint:gradeTop];
NSLayoutConstraint *gradeRight = [NSLayoutConstraint constraintWithItem:gradeLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:0];
[self.contentView addConstraint:gradeRight];
NSLayoutConstraint *gradeBottom = [NSLayoutConstraint constraintWithItem:gradeLabel attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[self.contentView addConstraint:gradeBottom];
}
- (void)awakeFromNib {
// Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
//
// NewAnnounceCell.m
// redstar
//
// Created by admin on 15/10/30.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import "NewAnnounceCell.h"
@implementation NewAnnounceCell
#pragma mark - System Methods
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
[self setup];
}
return self;
}
- (void)awakeFromNib {
// Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
#pragma mark - Private Methods
- (void)setup
{
self.announceLabel.textColor = kAnnounceTextColor;
self.pointLabel.text = @"···";
}
#pragma mark - Lazy Loading
- (UILabel *)announceLabel
{
if (!_announceLabel) {
_announceLabel = [[UILabel alloc] init];
_announceLabel.translatesAutoresizingMaskIntoConstraints = NO;
_announceLabel.font = [UIFont systemFontOfSize:15.0];
[self.contentView addSubview:_announceLabel];
NSLayoutConstraint *announceTop = [NSLayoutConstraint constraintWithItem:_announceLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:0];
[self.contentView addConstraint:announceTop];
NSLayoutConstraint *announceLeft = [NSLayoutConstraint constraintWithItem:_announceLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:20];
[self.contentView addConstraint:announceLeft];
NSLayoutConstraint *announceRight = [NSLayoutConstraint constraintWithItem:_announceLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.pointLabel attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
[self.contentView addConstraint:announceRight];
NSLayoutConstraint *announceBottom = [NSLayoutConstraint constraintWithItem:_announceLabel attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[self.contentView addConstraint:announceBottom];
}
return _announceLabel;
}
- (UILabel *)pointLabel
{
if (!_pointLabel) {
_pointLabel = [[UILabel alloc] init];
_pointLabel.textColor = kPointColor;
_pointLabel.translatesAutoresizingMaskIntoConstraints = NO;
_pointLabel.font = [UIFont systemFontOfSize:15.0];
[self.contentView addSubview:_pointLabel];
NSLayoutConstraint *pointTop = [NSLayoutConstraint constraintWithItem:_pointLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:0];
[self.contentView addConstraint:pointTop];
NSLayoutConstraint *pointWidth = [NSLayoutConstraint constraintWithItem:_pointLabel attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:20];
[self.contentView addConstraint:pointWidth];
NSLayoutConstraint *pointRight = [NSLayoutConstraint constraintWithItem:_pointLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-20];
[self.contentView addConstraint:pointRight];
NSLayoutConstraint *pointBottom = [NSLayoutConstraint constraintWithItem:_pointLabel attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[self.contentView addConstraint:pointBottom];
}
return _pointLabel;
}
@end
......@@ -7,10 +7,10 @@
//
#import <UIKit/UIKit.h>
#import "CustomPageControl.h"
@interface HomeHeaderView : UIView
@property (nonatomic, strong) UIScrollView *scrollView;
@property (nonatomic,strong) UILabel *weatherLabel;
@property (nonatomic, strong) CustomPageControl *customPageControl; // 自定义的pageControl
@end
......@@ -108,31 +108,35 @@
*/
- (void)loginButtonClick:(UIButton *)sender
{
if (self.loginView.usernameTextFiled.text.length == 0 || self.loginView.passwordTextFiled.text.length == 0) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"提示" message:@"账号、密码不能为空" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
[alertView show];
return;
}
// 进入RootTabBar
self.rootTBC = [[RootTabBarController alloc] init];
[self presentViewController:_rootTBC animated:YES completion:nil];
HttpClient *httpClient = [[HttpClient alloc] initWithLogin];
[httpClient loginWithUsername:self.loginView.usernameTextFiled.text password:self.loginView.passwordTextFiled.text completion:^(id response, NSError *error) {
if ([response[@"message"] isEqualToString:@"ok"]) {
// 保存登陆信息
[[NSUserDefaults standardUserDefaults] setObject:self.loginView.usernameTextFiled.text forKey:@"username"];
[[NSUserDefaults standardUserDefaults] setObject:self.loginView.passwordTextFiled.text forKey:@"password"];
[[NSUserDefaults standardUserDefaults] setObject:response[@"message"] forKey:@"loginMessage"];
[[NSUserDefaults standardUserDefaults] setObject:response[@"data"] forKey:@"loginData"];
// 进入RootTabBar
self.rootTBC = [[RootTabBarController alloc] init];
[self presentViewController:_rootTBC animated:YES completion:nil];
} else {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"提示" message:[NSString stringWithFormat:@"%@", response[@"message"]] delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
[alertView show];
}
}];
// if (self.loginView.usernameTextFiled.text.length == 0 || self.loginView.passwordTextFiled.text.length == 0) {
// UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"提示" message:@"账号、密码不能为空" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
// [alertView show];
// return;
// }
//
// HttpClient *httpClient = [[HttpClient alloc] initWithLogin];
// [httpClient loginWithUsername:self.loginView.usernameTextFiled.text password:self.loginView.passwordTextFiled.text completion:^(id response, NSError *error) {
// if ([response[@"message"] isEqualToString:@"ok"]) {
//
// // 保存登陆信息
// [[NSUserDefaults standardUserDefaults] setObject:self.loginView.usernameTextFiled.text forKey:@"username"];
// [[NSUserDefaults standardUserDefaults] setObject:self.loginView.passwordTextFiled.text forKey:@"password"];
// [[NSUserDefaults standardUserDefaults] setObject:response[@"message"] forKey:@"loginMessage"];
// [[NSUserDefaults standardUserDefaults] setObject:response[@"data"] forKey:@"loginData"];
//
// // 进入RootTabBar
// self.rootTBC = [[RootTabBarController alloc] init];
// [self presentViewController:_rootTBC animated:YES completion:nil];
//
// } else {
// UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"提示" message:[NSString stringWithFormat:@"%@", response[@"message"]] delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
// [alertView show];
// }
// }];
}
......
//
// CustomPageControl.h
// Parking
//
// Created by admin on 15/9/16.
// Copyright (c) 2015年 moobox. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface CustomPageControl : UIControl
@property(nonatomic) NSInteger numberOfPages; // 小点点的数量
@property(nonatomic) NSInteger currentPage; // 选中的小点点
@property(nonatomic) BOOL hidesForSinglePage ;
@property(nonatomic) BOOL defersCurrentPageDisplay ;
@property (nonatomic,retain) UIColor *onColor; // 选中小点点的颜色
@property (nonatomic,retain) UIColor *offColor; // 未选中小点点颜色
@property (nonatomic) CGFloat indicatorDiameter; // 小点点直径
@property (nonatomic) CGFloat indicatorSpace; // 小点点的间距
// 更新(重画)选中小点点
- (void)updateCurrentPageDisplay;
@end
//
// CustomPageControl.m
// Parking
//
// Created by admin on 15/9/16.
// Copyright (c) 2015年 moobox. All rights reserved.
//
#import "CustomPageControl.h"
#define kDotDiameter 4.0f
#define kDotSpace 12.0f
@implementation CustomPageControl
@synthesize numberOfPages ;
@synthesize currentPage ;
@synthesize hidesForSinglePage ;
@synthesize defersCurrentPageDisplay ;
@synthesize onColor ;
@synthesize offColor ;
@synthesize indicatorDiameter ;
@synthesize indicatorSpace ;
#pragma mark - init
- (id)init {
self = [self initWithFrame:CGRectZero] ;
return self ;
}
- (id)initWithFrame:(CGRect)frame {
if ((self = [super initWithFrame:CGRectZero])) {
self.backgroundColor = [UIColor clearColor] ;
}
return self ;
}
#pragma mark - drawRect
- (void)drawRect:(CGRect)rect {
// 获取上下文
CGContextRef context = UIGraphicsGetCurrentContext() ;
CGContextSaveGState(context) ;
CGContextSetAllowsAntialiasing(context, TRUE) ;
// 判断小点点直径 间距
CGFloat diameter = (indicatorDiameter > 0) ? indicatorDiameter : kDotDiameter ;
CGFloat space = (indicatorSpace > 0) ? indicatorSpace : kDotSpace ;
// 整个pageControl的bounds
CGRect currentBounds = self.bounds;
CGFloat dotsWidth = self.numberOfPages * diameter + MAX(0, self.numberOfPages - 1) * space;
CGFloat x = CGRectGetMidX(currentBounds) - dotsWidth / 2;
CGFloat y = CGRectGetMidY(currentBounds) - diameter / 2;
// 设置选中和未选中的小点点的颜色
CGColorRef onColorCG = onColor ? onColor.CGColor : [UIColor colorWithWhite: 1.0f alpha: 1.0f].CGColor ;
CGColorRef offColorCG = offColor ? offColor.CGColor : [UIColor colorWithWhite: 0.7f alpha: 0.5f].CGColor ;
// 遍历画(draw)点
for (int i = 0 ; i < numberOfPages ; i++)
{
CGRect dotRect = CGRectMake(x, y, diameter, diameter) ;
if (i == currentPage) {
CGContextSetFillColorWithColor(context, onColorCG) ;
CGContextFillEllipseInRect(context, CGRectInset(dotRect, -0.5f, -0.5f)) ;
} else {
CGContextSetStrokeColorWithColor(context, offColorCG) ;
CGContextStrokeEllipseInRect(context, dotRect) ;
}
x += diameter + space ;
}
// 恢复画板
CGContextRestoreGState(context) ;
}
#pragma mark - 重写setter方法
- (void)setCurrentPage:(NSInteger)pageNumber {
if (currentPage == pageNumber) {
return;
}
currentPage = MIN(MAX(0, pageNumber), numberOfPages - 1);
if (self.defersCurrentPageDisplay == NO) {
[self setNeedsDisplay];
}
}
- (void)setNumberOfPages:(NSInteger)numOfPages {
numberOfPages = MAX(0, numOfPages);
currentPage = MIN(MAX(0, currentPage), numberOfPages - 1);
self.bounds = self.bounds;
[self setNeedsDisplay];
if (hidesForSinglePage && (numOfPages < 2)) {
[self setHidden: YES];
} else {
[self setHidden: NO];
}
}
- (void)setHidesForSinglePage:(BOOL)hide {
hidesForSinglePage = hide ;
if (hidesForSinglePage && (numberOfPages < 2)){
[self setHidden:YES];
}
}
- (void)setDefersCurrentPageDisplay:(BOOL)defers {
defersCurrentPageDisplay = defers ;
}
- (void)setOnColor:(UIColor *)aColor {
onColor = aColor;
[self setNeedsDisplay];
}
- (void)setOffColor:(UIColor *)aColor {
offColor = aColor;
[self setNeedsDisplay];
}
- (void)setIndicatorDiameter:(CGFloat)aDiameter {
indicatorDiameter = aDiameter;
self.bounds = self.bounds;
[self setNeedsDisplay];
}
- (void)setIndicatorSpace:(CGFloat)aSpace {
indicatorSpace = aSpace;
self.bounds = self.bounds;
[self setNeedsDisplay];
}
- (void)setFrame:(CGRect)aFrame {
aFrame.size = [self sizeForNumberOfPages:numberOfPages];
super.frame = aFrame;
}
- (void)setBounds:(CGRect)aBounds {
aBounds.size = [self sizeForNumberOfPages: numberOfPages];
super.bounds = aBounds;
}
#pragma mark UIPageControl methods
- (void)updateCurrentPageDisplay {
if (self.defersCurrentPageDisplay == NO) {
return;
}
[self setNeedsDisplay] ;
}
- (CGSize)sizeForNumberOfPages:(NSInteger)pageCount {
CGFloat diameter = (indicatorDiameter > 0) ? indicatorDiameter : kDotDiameter;
CGFloat space = (indicatorSpace > 0) ? indicatorSpace : kDotSpace;
return CGSizeMake(pageCount * diameter + (pageCount - 1) * space + 44.0f, MAX(44.0f, diameter + 4.0f));
}
#pragma mark - Touches handlers
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
// 获取触摸的地方
UITouch *theTouch = [touches anyObject] ;
CGPoint touchLocation = [theTouch locationInView: self] ;
// 检测触摸的方向
if (touchLocation.x < (self.bounds.size.width / 2)) {
self.currentPage = MAX(self.currentPage - 1, 0);
} else {
self.currentPage = MIN(self.currentPage + 1, numberOfPages - 1);
}
[self sendActionsForControlEvents: UIControlEventValueChanged] ;
}
@end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment