零碎的代碼

1、UITableViewcell去掉點擊效果,UITableView不顯示默認分割線

//點擊無效果
cell.selectionStyle = UITableViewCellSelectionStyleNone;
//不現實默認的分隔線
tableView.separatorStyle = NO;

2、從plist文件中讀取資源

 NSArray *array = [NSArray arrayWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"data.plist" ofType:nil]];

    _data = [NSMutableArray array];
    for (NSDictionary *arr in array) {
        [_data addObject:[[egmenTationModel alloc] initWithDic:arr]];
    }

3、代碼創建分隔線

//    顯示分割線  調整座標可以創建想要的 橫線或者豎線
    CGRect carveUpRect = CGRectMake(10, 103, 100,2);
    UILabel* carveup = [[UILabel alloc]initWithFrame:carveUpRect];
    carveup.layer.borderColor = [UIColor colorWithRed:204.0f/255 green:204.0f/255 blue:204.0f/255 alpha:1].CGColor;
    //邊框的顏色需要帶.CGColor才能設置上
    carveup.layer.borderWidth = 1;

4、IOS標題欄、導航欄、應用程序界面大小等宏定義。

#define fDeviceWidth ([UIScreen mainScreen].bounds.size.width)
#define fDeviceHeight ([UIScreen mainScreen].bounds.size.height)
#define APP_Frame_Height   [[UIScreen mainScreen] applicationFrame].size.height //應用程序的屏幕高度
#define App_Frame_Width    [[UIScreen mainScreen] applicationFrame].size.width  //應用程序的屏幕寬度

// 狀態欄(statusbar)
#define StatusBarHeight ([[UIApplication sharedApplication] statusBarFrame].size.height)
//導航欄
#define NavigationBarHeight  (self.navigationController.navigationBar.frame.size.height)
#define TOPBARHEIGHT (StatusBarHeight+NavigationBarHeight)

5、pch文件的創建
需要在Build Settings->Apple LLVM 6.0-Language
配置prefix Header 路徑 例如: $(SRCROOT)/TextDemo/myHeader.pch

6、去掉NavigationBar返回按鈕旁邊的文字;設置NAvigationBar是否隱藏;從navigationControllor推出新的視圖控制器。

 //  去掉返回鍵盤上面的文字
UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStyleDone target:nil action:nil];
 [self.navigationItem setBackBarButtonItem:backItem];

 [self.navigationController setNavigationBarHidden:NO animated:NO];
 //並將視圖控制器添加到根視圖控制器中 並顯示出來
 [self.navigationController pushViewController:etdtVC animated:YES];

7、imageView上加圖片

//這種加載方法好一點
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"6" ofType:@"jpg"];
    NSData *data=[NSData dataWithContentsOfFile:filePath];
    UIImage *image=[UIImage imageWithData:data];
    imageView.contentMode=UIViewContentModeScaleToFill;
    imageView.clipsToBounds=YES;//隱藏超出的那部分
    [imageView setImage:image];
/**
UIViewContentModeScaleToFill
UIViewContentModeScaleAspectFit
UIViewContentModeScaleAspectFill
UIViewContentModeRedraw
UIViewContentModeCenter
UIViewContentModeTop
UIViewContentModeBottom
UIViewContentModeLeft
UIViewContentModeRight
UIViewContentModeTopLeft
UIViewContentModeTopRight
UIViewContentModeBottomLeft
UIViewContentModeBottomRight

注意以上幾個常量,凡是沒有帶Scale的,當圖片尺寸超過 
ImageView尺寸時,只有部分顯示在ImageView中。UIViewContentModeScaleToFill屬性會導致圖片變形。UIViewContentModeScaleAspectFit會保證圖片比例不變,而且全部顯示在ImageView中,這意味着ImageView會有部分空白。UIViewContentModeScaleAspectFill也會證圖片比例不變,但是是填充整個ImageView的,可能只有部分圖片顯示出來。

*/
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章