您的位置:首页 > 移动开发 > IOS开发

ios 常用放法、设置

2016-07-25 09:51 465 查看
//状态栏高度

CGFloat statusBarH = [[UIApplication sharedApplication] statusBarFrame].size.height;

//导航栏高度

CGFloat navigationBarH = self.navigationController.navigationBar.frame.size.height;

-------------------------------------------------------------------------------------------------------------------------------------------------------------

//设置导航栏背景颜色

    self.navigationController.navigationBar.barTintColor = RGBA(46, 148, 255, 1);

 //设置导航栏标题字体大小、颜色

    [[self.navigationController navigationBar] setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:17], NSForegroundColorAttributeName:[UIColor whiteColor]}];

-------------------------------------------------------------------------------------------------------------------------------------------------------------

//键盘回收

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{

    

    UITouch *touch = [touches anyObject];

    

    if (![touch.view isKindOfClass: [UITextField class]] || ![touch.view isKindOfClass: [UITextView class]]) {

        

        [self.view endEditing:YES];

        

    }

    
}

-------------------------------------------------------------------------------------------------------------------------------------------------------------

//动画退出

- (void)exitApplication {

    AppDelegate *app = [UIApplication sharedApplication].delegate;

    UIWindow *window = app.window;

    

    [UIView animateWithDuration:0.5f animations:^{

        window.alpha = 0;

        window.frame = CGRectMake(0, window.bounds.size.width, 0, 0);

    } completion:^(BOOL finished) {

        exit(0);

    }];

}

-------------------------------------------------------------------------------------------------------------------------------------------------------------

//UILabel 字体居中设置

label.textAlignment = NSTextAlignmentCenter;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: