成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

iOS開發(fā) UItableView中的單元格背景漸變

移動(dòng)開發(fā) iOS
漸變?nèi)绻帽尘皥D片,會(huì)讓你的app臃腫。給APP瘦身,我們可以使用代碼來解決漸變的問題。這篇文章是解決表格中的單元格的簡便問題,同時(shí)解決單元格外邊框問題。

iOS iPhone 開發(fā) UItableView中的單元格背景漸變

漸變?nèi)绻帽尘皥D片,會(huì)讓你的app臃腫。給APP瘦身,我們可以使用代碼來解決漸變的問題。這篇文章是解決表格中的單元格的簡便問題,同時(shí)解決單元格外邊框問題。

1:設(shè)置好開始顏色與結(jié)束顏色。推薦一個(gè)小工具,在chrome瀏覽器上安裝一個(gè)擴(kuò)展 chroma 這個(gè)東西能幫助你很好的選擇顏色。

下載地址:https://chrome.google.com/webstore/detail/chroma/gefgglgjdlddcpcapigheknbacbmmggp

[[75464]]

2:接下來就是代碼了 

創(chuàng)建一個(gè) CellbackgroundVIew 

CellbackgroundVIew.h

  1. #import <UIKit/UIKit.h> 
  2.     @interface CellbackgroundVIew : UIView 
  3.     @end 

CellbackgroundVIew.m

  1. #import "CellbackgroundVIew.h" 
  2.     @implementation CellbackgroundVIew 
  3.     - (void)drawRect:(CGRect)rect 
  4.     { 
  5.         CGContextRef context = UIGraphicsGetCurrentContext(); 
  6.  
  7.         CGColorSpaceRef colorSpaceRef = CGColorSpaceCreateDeviceRGB();    
  8.         // 創(chuàng)建起點(diǎn)顏色 白色 
  9.         CGColorRef beginColor = CGColorCreate(colorSpaceRef, (CGFloat[]){1.0f, 1.0f, 1.0f, 1.0f}); 
  10.         // 創(chuàng)建終點(diǎn)顏色 灰色 RGB(212,212,212) 這個(gè)色值我們可以從chroma擴(kuò)展插件中選擇 
  11.     <pre class="brush:cpp; toolbar: true; auto-links: false;">   //(CGFloat[]){0.83f, 0.83f, 0.83f, 1.0f} 0.83是 212/255的值</pre> 
  12.     CGColorRef endColor = CGColorCreate(colorSpaceRef, (CGFloat[]){0.83f, 0.83f, 0.83f, 1.0f}); 
  13.         CGRect paperRect = self.bounds; 
  14.         CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); 
  15.         CGFloat locations[] = {0.0,1.0}; 
  16.         NSArray *colors = [NSArray arrayWithObjects:(__bridge id)beginColor,(__bridge id)endColor, nil]; 
  17.         CGGradientRef gradient = CGGradientCreateWithColors(colorSpace, (CFArrayRef)CFBridgingRetain(colors), locations); 
  18.         CGPoint startPoint = CGPointMake(CGRectGetMidX(rect), CGRectGetMinY(rect)); 
  19.         CGPoint endPoint = CGPointMake(CGRectGetMidX(rect), CGRectGetMaxY(rect)); 
  20.         CGContextSaveGState(context); 
  21.         CGContextAddRect(context, rect); 
  22.         CGContextClip(context); 
  23.         CGContextDrawLinearGradient(context, gradient, startPoint, endPoint, 0); 
  24.         CGContextRestoreGState(context); 
  25.         CGGradientRelease(gradient); 
  26.         CGColorSpaceRelease(colorSpace); 
  27.         //add line stroke 
  28.         CGRect strokeRect = CGRectInset(paperRect, 5.0, 5.0); 
  29.         CGColorRef lineColor = CGColorCreate(colorSpaceRef, (CGFloat[]){0.83f, 0.83f, 0.83f, 1.0f}); 
  30.         CGContextSetStrokeColorWithColor(context, lineColor); 
  31.         CGContextSetLineWidth(context, 1.0); 
  32.         CGContextStrokeRect(context, strokeRect); 
  33.     } 
  34.     @end 

在表格中我們的cell 可以設(shè)置backgroundview

  1. [cell setBackgroundView: [[CellbackgroundVIew alloc] init]]; 

 

責(zé)任編輯:閆佳明 來源: oschina
相關(guān)推薦

2010-08-11 16:41:30

Flex DataGr

2015-01-15 16:34:31

iOS源碼單元格

2009-08-07 17:54:41

C#單元格數(shù)據(jù)

2010-04-27 11:11:06

Oracle修改JTa

2011-07-07 16:38:21

iOS UITableVie

2023-06-07 10:41:43

2021-08-13 11:10:32

OpenPyXLExcelPython

2009-07-28 03:44:00

GridViewRow

2009-07-27 16:46:07

DetailsView

2013-07-25 14:12:53

iOS開發(fā)學(xué)習(xí)UITableView

2021-09-09 08:58:32

Excel數(shù)據(jù)處理函數(shù)

2011-08-15 13:44:07

iPhone開發(fā)UITableView

2013-06-20 11:21:58

iOS開發(fā)UITableView

2012-04-04 22:36:52

iOS5

2015-03-18 09:29:12

iOS開發(fā)爭議

2010-08-26 10:42:18

CSStr td

2021-11-15 07:45:06

CSS 技巧背景光動(dòng)畫

2023-06-30 13:27:54

CSS徑向漸變

2021-04-16 05:54:05

CSS 文字動(dòng)畫技巧

2010-08-11 16:30:49

Flex DataGr
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)

主站蜘蛛池模板: 亚洲欧美中文日韩在线 | 欧美一区二区综合 | 欧美日韩在线成人 | 国产一区2区 | 一本大道久久a久久精二百 国产成人免费在线 | 国产视频一区二区三区四区五区 | 97精品国产97久久久久久免费 | 国产精品视频一区二区三 | av一级一片 | 日本不卡一区二区三区在线观看 | 99爱免费| 中文字幕视频一区二区 | 国产精品久久久久aaaa九色 | 亚洲高清在线 | 国产高清视频在线 | 国产精品精品视频一区二区三区 | 黄色片在线观看网址 | 午夜一区二区三区在线观看 | 草草视频在线播放 | 久久在线| 久久视频一区 | 国产精品精品久久久 | 天天操天天干天天爽 | 最新国产视频 | av午夜电影 | 四虎影音 | 久久精品99久久 | 性一交一乱一伦视频免费观看 | 欧州一区二区 | 天天艹天天干天天 | 亚洲精品日韩一区二区电影 | 亚洲女人天堂成人av在线 | 国产成人在线一区二区 | 天堂资源视频 | 久久亚洲美女 | 天天干视频在线 | 久久伊人影院 | 91精品国产一区二区三区 | 在线观看成人 | 色综合一区 | 欧美日本在线 |