平時遇到的問題的總結和一些開發小技巧

1. StoryBoard中scrollview不能滑動

解決方法:在如下方法中定義contentsize

-(void)viewDidLayoutSubviews

{

self.scrollView.contentSize = CGSizeMake(712,1000);

}

2. 項目只支持豎屏

解決辦法:?在General->Device Orientation里只勾選了portrait, 取消勾選其他的

3.改變導航欄title的顏色

[self.navigationController.navigationBarsetTitleTextAttributes:[NSDictionarydictionaryWithObjectsAndKeys:[UIColorwhiteColor],NSForegroundColorAttributeName,nil]];

4.自定義導航欄的title

UILabel* titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(0,0,100,44)];

titleLabel.backgroundColor= [UIColorclearColor];//設置Label背景透明

titleLabel.font= [UIFontboldSystemFontOfSize:24];//設置文本字體與大小

titleLabel.textColor= [UIColorwhiteColor];//設置文本顏色

titleLabel.baselineAdjustment=UIBaselineAdjustmentAlignCenters;//設置居中

titleLabel.text=@"通知";//設置標題

self.navigationItem.titleView = titleLabel;

5.狀態欄字體顏色的設置

在info.plist文件里面 添加View controller–based status bar appearance 并設置為NO

在UIViewController里的viewWillApper或viewDidAppear里面加入[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];

6.tableView上面多出來的那一部分

self.automaticallyAdjustsScrollViewInsets=false

7.tableView不想讓多余的cell顯示出來

self.tableView.tableFooterView= [[UIViewalloc]initWithFrame:CGRectZero];

8.tabBar的圖片默認會被渲染, 得到不被渲染的效果

self.tabBarController.tabBar.selectedItem.selectedImage = [[UIImage imageNamed:@"TabBar_Discovery_Sel"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容