国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 學(xué)院 > 開(kāi)發(fā)設(shè)計(jì) > 正文

主程序底部TabBar功能跟登錄頁(yè)面布局

2019-11-14 18:39:10
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

1:主程序底部TabBar的功能實(shí)現(xiàn)

效果圖:

 

主要代碼如下:

- (UITabBarController*)setRootVC:(BOOL)bShowCart{    //創(chuàng)建一個(gè)子控制器 用于顯示當(dāng)前的tab    TabHomeVC *homeVC = [[TabHomeVC alloc] init];    //每個(gè)tab都是一個(gè)nav的內(nèi)容,這樣每個(gè)都是自個(gè)的nav,進(jìn)行跳轉(zhuǎn)    UINavigationController *homeNav = [[UINavigationController alloc] initWithRootViewController:homeVC];    UIImage *unselectedImage = [UIImage imageNamed:@"tab-home"];    UIImage *selectedImage = [UIImage imageNamed:@"tab-home-s"];        homeVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"首頁(yè)"                                                      image:[unselectedImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]                                              selectedImage:[selectedImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];    homeVC.tabBarItem.tag = 0;        TabPRoductVC *proVC = [[TabProductVC alloc] init];    UINavigationController *proNav = [[UINavigationController alloc] initWithRootViewController:proVC];    unselectedImage = [UIImage imageNamed:@"tab-pro"];    selectedImage = [UIImage imageNamed:@"tab-pro-s"];        proNav.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"所有商品"                                                      image:[unselectedImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]                                              selectedImage:[selectedImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];    proNav.tabBarItem.tag = 1;        TabNewestVC * newVc = [[TabNewestVC alloc] init];    UINavigationController * newNav = [[UINavigationController alloc] initWithRootViewController:newVc];    unselectedImage = [UIImage imageNamed:@"tab-new"];    selectedImage = [UIImage imageNamed:@"tab-new-s"];        newNav.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"最新揭曉"                                                       image:[unselectedImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]                                               selectedImage:[selectedImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];    newNav.tabBarItem.tag = 2;        TabShopCartVC * cartVc = [[TabShopCartVC alloc] init];    UINavigationController * cartNav = [[UINavigationController alloc] initWithRootViewController:cartVc];    unselectedImage = [UIImage imageNamed:@"tab-cart"];    selectedImage = [UIImage imageNamed:@"tab-cart-s"];        cartNav.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"購(gòu)物車(chē)"                                                      image:[unselectedImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]                                              selectedImage:[selectedImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];    cartNav.tabBarItem.tag = 3;        TabMineVC * mineVc = [[TabMineVC alloc] init];    UINavigationController * mineNav = [[UINavigationController alloc] initWithRootViewController:mineVc];    unselectedImage = [UIImage imageNamed:@"tab-mine"];    selectedImage = [UIImage imageNamed:@"tab-mine-s"];        mineNav.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"我的云購(gòu)"                                                       image:[unselectedImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]                                               selectedImage:[selectedImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];    mineNav.tabBarItem.tag = 4;            //把上面的控制器增加到uitabbarcontroller的數(shù)組里    UITabBarController *tabBarController = [[UITabBarController alloc] init];    if(bShowCart)        tabBarController.viewControllers = @[homeNav,proNav,newNav,cartNav,mineNav];    else        tabBarController.viewControllers = @[homeNav,proNav,newNav,mineNav];    tabBarController.delegate = self;            //設(shè)置一些樣式內(nèi)容    // customise TabBar UI Effect    [UITabBar appearance].tintColor = BG_COLOR;        [[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:TABBAR_TEXT_NOR_COLOR} forState:UIControlStateNormal];    [[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:TABBAR_TEXT_HLT_COLOR} forState:UIControlStateSelected];        // customise NavigationBar UI Effect    [[UINavigationBar appearance] setBackgroundImage:[UIImage imageWithRenderColor:NAVBAR_COLOR renderSize:CGSizeMake(10., 10.)] forBarMetrics:UIBarMetricsDefault];    [[UINavigationBar appearance] setTitleTextAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:16.],NSForegroundColorAttributeName:[UIColor blackColor]}];            UITabBar *tabBar = tabBarController.tabBar;    tabBar.backgroundColor = BG_COLOR;        return tabBarController;}- (void)setCartNum{    //獲得UITabBarController    UITabBarController* tabVC = (UITabBarController*)self.window.rootViewController;    //獲得其中第四個(gè) 也就是購(gòu)物車(chē)那個(gè)tabbar    UINavigationController* navVC = [tabVC.viewControllers objectAtIndex:3];    __weak typeof (navVC) wNav = navVC;    //給它增加一個(gè)數(shù)字標(biāo)識(shí)    [CartModel quertCart:nil value:nil block:^(NSArray* result){        if(result.count > 0)            wNav.tabBarItem.badgeValue  = [NSString stringWithFormat:@"%d",(int)result.count];        else            wNav.tabBarItem.badgeValue  = nil;    }];}- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    [self setWindow:[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]];    //加載初始化的那個(gè)tab    UIViewController *rootViewController = [self setRootVC:YES];    [[self window] setRootViewController:rootViewController];    //顯示是否有數(shù)字標(biāo)識(shí)    [self setCartNum];    // set  backgroundColor    [[self window] setBackgroundColor:[UIColor whiteColor]];    // set  makeKeyAndVisible    [[self window] makeKeyAndVisible];    return YES;}

注意:這邊為每個(gè)tabBarController的子控件都增加一個(gè)nav,這樣就可以在每個(gè)選項(xiàng)卡里都實(shí)現(xiàn)nav的跳轉(zhuǎn),把這個(gè)tabBarController作為整個(gè)的rootViewController;其中在其它控制器調(diào)用AppDelegate的方法setCarNum,可以[(AppDelegate*)[[UIApplication sharedApplication] delegate] setCartNum];

 

2:登錄頁(yè)面兩輸入框效果的實(shí)現(xiàn)

效果圖:

 

主要代碼:

- (void)viewDidLoad {    [super viewDidLoad];        self.title = @"登錄";    self.view.backgroundColor = [UIColor hexFloatColor:@"f8f8f8"];    __weak typeof (self) wSelf = self;    [self actionCustomLeftBtnWithNrlImage:@"btnback" htlImage:@"btnback" title:@"" action:^{        [wSelf btnBackAction];    }];        UIImageView* line1 = [[UIImageView alloc] initWithFrame:CGRectMake(16, 20, mainWidth - 32, 0.5)];    line1.backgroundColor = [UIColor hexFloatColor:@"dedede"];    [self.view addSubview:line1];        UIImageView* line3 = [[UIImageView alloc] initWithFrame:CGRectMake(16, 108, mainWidth - 32, 0.5)];    line3.backgroundColor = [UIColor hexFloatColor:@"dedede"];    [self.view addSubview:line3];        UIImageView* line4 = [[UIImageView alloc] initWithFrame:CGRectMake(16, 20, 0.5, 88)];    line4.backgroundColor = [UIColor hexFloatColor:@"dedede"];    [self.view addSubview:line4];        UIImageView* line5 = [[UIImageView alloc] initWithFrame:CGRectMake(mainWidth - 16, 20, 0.5, 88)];    line5.backgroundColor = [UIColor hexFloatColor:@"dedede"];    [self.view addSubview:line5];        UIView* vUser = [[UIView alloc] initWithFrame:CGRectMake(16.5, 20.5, mainWidth - 33, 87)];    vUser.backgroundColor = [UIColor whiteColor];    [self.view addSubview:vUser];        UIImageView* line2 = [[UIImageView alloc] initWithFrame:CGRectMake(16, 64, mainWidth - 32, 0.5)];    line2.backgroundColor = [UIColor hexFloatColor:@"dedede"];    [self.view addSubview:line2];    UIImageView* imgUser = [[UIImageView alloc] initWithFrame:CGRectMake(10, 12, 20, 20)];    imgUser.image = [UIImage imageNamed:@"login_name"];    [vUser addSubview:imgUser];        txtUser = [[UITextField alloc] initWithFrame:CGRectMake(35, 0, vUser.frame.size.width - 35, 44)];    txtUser.placeholder = @"請(qǐng)輸入您的手機(jī)號(hào)/郵箱號(hào)";    txtUser.clearButtonMode = UITextFieldViewModeWhileEditing;    txtUser.font = [UIFont systemFontOfSize:14];    txtUser.text = [[NSUserDefaults standardUserDefaults] objectForKey:kLoginUsername];    [vUser addSubview:txtUser];        UIImageView* imgPwd = [[UIImageView alloc] initWithFrame:CGRectMake(10, 56, 20, 20)];    imgPwd.image = [UIImage imageNamed:@"login_passWord"];    [vUser addSubview:imgPwd];        txtPwd = [[UITextField alloc] initWithFrame:CGRectMake(35, 44, vUser.frame.size.width - 35, 44)];    txtPwd.placeholder = @"請(qǐng)輸入您的密碼";    txtPwd.clearButtonMode = UITextFieldViewModeWhileEditing;    txtPwd.font = [UIFont systemFontOfSize:14];    txtPwd.secureTextEntry = YES;    [vUser addSubview:txtPwd];        UIButton* btnLogin = [[UIButton alloc] initWithFrame:CGRectMake(16, 120, mainWidth - 32, 44)];    btnLogin.layer.cornerRadius = 5;    btnLogin.backgroundColor = mainColor;    [btnLogin setTitle:@"登錄" forState:UIControlStateNormal];    [btnLogin addTarget:self action:@selector(btnLoginAction) forControlEvents:UIControlEventTouchUpInside];    [self.view addSubview:btnLogin];        UIButton* btnReg = [[UIButton alloc] initWithFrame:CGRectMake(mainWidth - 120, 170, 100, 44)];    [btnReg setTitle:@"新用戶注冊(cè)" forState:UIControlStateNormal];    btnReg.titleLabel.font = [UIFont systemFontOfSize:13];    [btnReg setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];    [btnReg addTarget:self action:@selector(btnRegAction) forControlEvents:UIControlEventTouchUpInside];    [self.view addSubview:btnReg];}

注意:它是通過(guò)幾條背景線跟圖片和輸入框進(jìn)行一個(gè)組合


發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 长葛市| 桂东县| 许昌县| 兴业县| 义马市| 和顺县| 盐源县| 丁青县| 吴旗县| 丁青县| 新巴尔虎右旗| 古蔺县| 兴国县| 教育| 东台市| 临西县| 招远市| 德阳市| 三河市| 马鞍山市| 甘洛县| 玉田县| 顺平县| 嘉峪关市| 高邮市| 巴青县| 嘉鱼县| 婺源县| 磐安县| 外汇| 桐梓县| 芮城县| 黄平县| 福鼎市| 久治县| 子长县| 基隆市| 新源县| 康平县| 红桥区| 三穗县|