分类: IOS开发

14 篇文章

IOS修改UITabBarController选项图片文本颜色
IOS使用UITabBarController比较多,UITabBarController默认的tabBarItem为灰色和蓝色,是系统默认的,修改如下: UITabBarController *tabBar = [[UITabBarController alloc] init]; tabBar.tabBar.tintColor = [UIColo…
IOS修改状态栏字体颜色为白色
步骤如下: 1、修改info.plist选项View controller-based status bar appearance为NO 2、在app delegate中:[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
IOS计算文本大小
计算文本所占空间大小,已解决UILabel内容自适应的问题。经测试下面代码可用: /** * 计算文本的宽高 * @param str 需要计算的文本 * @param font 文本显示的字体 * @param maxSize 文本显示的范围 * @return 文本占用的真实宽高 */ - (CGSize)sizeWithString:(NSS…
NSArray转成json字符串
NSString *jsonArray = @""; NSMutableArray *array = [[NSMutableArray alloc] init]; for (int i=0; i
关闭多个UIViewController时报异常:Trying to dismiss the presentation controller while transitioning already
关闭多个UIViewController时报异常,google了下,用下面代码可以避免,具体原因可能是关闭一个UIViewController影响到了其他的UIViewController,所以需要关闭了以后再关闭另一个,不能使用循环一下同时关闭多个,不知对不对,还请高手指教。上代码: //这个是我定义的数组,放了多个需要关闭的UIViewCont…
UITableView默认选中第一行
UITableView默认选中第一行,代码如下: NSIndexPath *indexPath=[NSIndexPath indexPathForRow:0 inSection:0]; [_tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewS…
动态计算UITableView每一行的高度
开发中可能会遇到UITableView每一行的高度不一样,可以根据每行不通的内容返回不同高度,修改UITableViewDelegate代理方法如下: - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { UI…
设置UIImageView为圆角
开发中需要设置用户头像显示为圆角,代码如下: headimg.layer.masksToBounds=YES; headimg.layer.cornerRadius=headimg.frame.size.width/2.0f; //设置为图片宽度的一半出来为圆形 headimg.layer.borderWidth=2.0f; //边框宽度 head…
UITabBarController使用代码跳转元素
项目需要,一个界面中有一个按钮,点击可以切换tabBarController的子界面,代码如下,记录下: [self.tabBarController setSelectedIndex:2]; 原创内容转载请保留出处GEEK笔记(http://www.geekapp.cn/)。
storyboard界面跳转
UIStoryboard *secondStroyBoard=[UIStoryboard storyboardWithName:@"LoginRegister" bundle:nil]; UIViewController *login=[secondStroyBoard instantiateViewControllerWithIdentifier…