多多色-多人伦交性欧美在线观看-多人伦精品一区二区三区视频-多色视频-免费黄色视屏网站-免费黄色在线

國內(nèi)最全I(xiàn)T社區(qū)平臺 聯(lián)系我們 | 收藏本站
阿里云優(yōu)惠2
您當(dāng)前位置:首頁 > php開源 > 綜合技術(shù) > 仿網(wǎng)易彩票代碼實現(xiàn)

仿網(wǎng)易彩票代碼實現(xiàn)

來源:程序員人生   發(fā)布時間:2014-12-13 08:44:07 閱讀次數(shù):3929次

仿網(wǎng)易彩票代碼實現(xiàn)

1.設(shè)置全部導(dǎo)航條的背景

// 取出全部導(dǎo)航條
UINavigationBar *bar = [UINavigationBar appearance];
// 設(shè)置全部導(dǎo)航條的背景圖片
[bar setBackgroundImage:[UIImage imageName:
@"navigationbar_background.png"] forBarMetrics:UIBarMetricsDefault];
// 導(dǎo)航欄上有1層BackgroundImageView,不能直接設(shè)置背景色彩,設(shè)置背景色彩是無效的
//  bar.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"navigationbar_background.png"]];

// 設(shè)置所有導(dǎo)航條字體的色彩
NSDictionary *dict = @{NSFontAttributeName: [UIFont systemFontOfSize:15.0],NSForegroundColorAttributeName:[UIColor whiteColor]};
 [
bar setTitleTextAttributes:dict];
// 設(shè)置主題色彩
[
bar setTintColor:[UIColor whiteColor]];
2、解決IOS6和IOS7兼容性問題
程序啟動的時候,隱藏狀態(tài)欄,ios6需要恢復(fù)狀態(tài)欄顯示
設(shè)置狀態(tài)欄色彩 ios7默許狀態(tài)欄交給控制器管理,修改info.plist文件,讓狀態(tài)欄交給application管理
application.statusBarHidden = NO;
application.
statusBarStyle = UIStatusBarStyleLightContent;
3、自定義button,設(shè)置button的標(biāo)題和圖片的位置
// 設(shè)置按鈕標(biāo)題的位置
- (
CGRect)titleRectForContentRect:(CGRect)contentRect;
// 設(shè)置按鈕圖片的位置
- (CGRect)
imageRectForContentRect:(CGRect)contentRect;
// 獲得當(dāng)前文字尺寸計算內(nèi)部Label的尺寸
NSDictionary *dict = @{NSFontAttributeName: [UIFont systemFontOfSize:15.0]};
titleW = [self.currentTitle boundingRectWithSize:CGSizeMake(MAXFLOAT, MAXFLOAT) options:NSStringDrawingTruncatesLastVisibleLine attributes:dict context:nil].size.width;
注意:IOS6和IOS7有兼容性問題
boundingRectWithSizeios7才有,ios6沒有這個方法。
IOS6需要用這個方法,獲得當(dāng)前文字的尺寸,計算內(nèi)部Label的尺寸。
titleW = [self.currentTitle sizeWithFont:[UIFont systemFontOfSize:15.0]].width;
4、button imagestroyboard的拉伸
注意:
通過storyboard只能拉伸UIImageView,而buttonstoryboard不能拉伸,只能用代碼實現(xiàn)。  
 storyboard x:表示左側(cè)多少不拉伸 y:表示上邊多少不拉伸 w:表示寬度拉伸多少個像素 h:表示高度拉伸多少個像素 x:0.5(左側(cè)1半不拉伸) y:0.5(頂部1半不拉伸) w:0 (寬度拉伸1個像素) h:0(高度拉伸1個像素)。
  
// 拉伸按鈕
UIImage *image = [UIImage imageNamed:@"NavButton"];
UIImage *imageH = [UIImage imageNamed:@"NavButtonPressed"];
image = [image
stretchableImageWithLeftCapWidth:image.size.width * 0.5  topCapHeight:image.size.height * 0.5];
imageH = [imageH
stretchableImageWithLeftCapWidth:imageH.size.width * 0.5 topCapHeight:imageH.size.height * 0.5];
[
_loginBtn setBackgroundImage:image forState:UIControlStateNormal];
[
_loginBtn setBackgroundImage:imageH forState:UIControlStateHighlighted];
5、UICollectionViewController
UICollectionViewController默許有1個UICollectionView,但是self.collectionView != self.view
UITableViewController默許有1個UITableView,并且self.tableview == self.view

UICollectionViewCell是不能通過代碼來創(chuàng)建的,forIndexPath意味著去stroyboard中創(chuàng)建。
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:ID forIndexPath:indexPath];
UICollectionViewCell *cell = [[UICollectionViewCell alloc] init];
UICollectionViewCell首先會從緩存池中根據(jù)Identifier查找,如果緩存池中沒有,才會手動創(chuàng)建,但是手動創(chuàng)建init方法沒有提供標(biāo)識符的構(gòu)造方法,在做系統(tǒng)優(yōu)化的時候,就不能根據(jù)Identifier準(zhǔn)確的查找出,會引發(fā)表格的重用。

// 1.注冊cell(告知collectionView將來創(chuàng)建怎樣的cell),利用xib創(chuàng)建
UINib *nib = [UINib nibWithNibName:@"SUNProductCell" bundle:nil];
[
self.collectionView registerNib:nib forCellWithReuseIdentifier:ID];

// 2.注冊UICollectionViewCell ,如果緩存池中沒有,就會自動創(chuàng)建
[self.collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:ID];

注意:在使用UICollectionViewCell 必須傳入布局。
    // 1.流水布局
   
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
   
// 2.每一個cellframe
    layout.
itemSize = CGSizeMake(80, 80);
   
// 3.設(shè)置cell之間的水平間距
    layout.
minimumInteritemSpacing = 0;
   
// 4.設(shè)置cell之間的垂直間距
    layout.
minimumLineSpacing = 10;
   
// 5.設(shè)置4周的內(nèi)邊距
    layout.
sectionInset = UIEdgeInsetsMake(layout.minimumLineSpacing, 0, 0, 0);
   
return [super initWithCollectionViewLayout:layout];

使用UICollectionView 
    第1步:必須有布局
   
第2部:cell必須自己注冊
6、解析JSON數(shù)據(jù)
NSString *fileName = [[NSBundle mainBundle] pathForResource:@"products.json" ofType:nil];
NSData *data =  [NSData dataWithContentsOfFile:fileName];
NSArray *jsonArr =  [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
7、UIWebView
// 加載資源包中的html
NSURL *url = [[NSBundle mainBundle] URLForResource:_helpItem.html withExtension:nil];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[webView
loadRequest:request];
// 加載完網(wǎng)頁調(diào)用
- (
void)webViewDidFinishLoad:(UIWebView *)webView
{
   
NSString *str = [NSString stringWithFormat:@"window.location.href = '#%@';",_helpItem.ID];
    [webView
stringByEvaluatingJavaScriptFromString:str];
}
生活不易,碼農(nóng)辛苦
如果您覺得本網(wǎng)站對您的學(xué)習(xí)有所幫助,可以手機(jī)掃描二維碼進(jìn)行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關(guān)閉
程序員人生
主站蜘蛛池模板: 91视频一区二区 | 欧美在线精品永久免费播放 | 国产精品视频流白浆免费视频 | 国产又黄又免费aaaa视频 | 亚洲国产精品ⅴa在线观看 亚洲国产精品aaa一区 | 欧美一区网站 | 免费播放观看在线视频 | 亚洲精品国产啊女成拍色拍 | 视频一区色眯眯视频在线 | 国产在线欧美日韩一区二区 | 在线观看麻豆精品国产不卡 | 亚洲黄色在线看 | 亚洲看逼| 欧美淫 | 久久精品在线视频 | 在线观看成年人视频网站 | 日本三级日本三级日本三级极 | 成人自拍视频在线观看 | 日本爱爱小视频 | 亚洲产国偷v产偷v自拍涩爱 | 免费国产成人高清在线观看不卡 | 国产精品69白浆在线观看免费 | 亚洲天堂中文字幕在线观看 | 日本xxxwww在线观看免费 | 欧美日本成人 | 99国产精品久久久久久久成人热 | 国产精品欧美日韩精品 | 男女免费爽爽爽在线视频 | xx综合网| 外国一级黄色毛片 | 欧美亚洲精品一区 | 能看毛片的网址 | 日本一级淫片免费放 | 国产一区二区三区播放 | jizz性欧美3 jizz亚洲 | 欧美性大战久久久久久久蜜桃 | аⅴ中文在线天堂 | 在线播放人成午夜免费视频 | 亚洲综合色网站 | 亚洲h视频 | 亚洲精品自拍 |