欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

iOS7UITableView做成類似iOS6風(fēng)格-創(chuàng)新互聯(lián)

iOS7扁平化設(shè)計(jì)已經(jīng)成為了一個(gè)趨勢基于對(duì)老版本的臨時(shí)修改UITableView在sytle是group的時(shí)候是個(gè)×××煩沒辦法改就改吧。

成都創(chuàng)新互聯(lián)公司專注于網(wǎng)站建設(shè),為客戶提供成都做網(wǎng)站、成都網(wǎng)站制作、成都外貿(mào)網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計(jì)開發(fā)服務(wù),多年建網(wǎng)站服務(wù)經(jīng)驗(yàn),各類網(wǎng)站都可以開發(fā),品牌網(wǎng)站設(shè)計(jì),公司官網(wǎng),公司展示網(wǎng)站,網(wǎng)站設(shè)計(jì),建網(wǎng)站費(fèi)用,建網(wǎng)站多少錢,價(jià)格優(yōu)惠,收費(fèi)合理。

    直接用圖片的方式是最簡單的設(shè)置一個(gè)背景圖拖一個(gè)UIImageView到你的Custom Cell中去設(shè)置普通和高亮情況下的p_w_picpath針對(duì)iOS7修改內(nèi)部元素的frame設(shè)置默認(rèn)的北京view為空代碼如下

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    ...........
    UIView *testView2 = [[UIView alloc] init];
    testView2.backgroundColor = UIColor.clearColor;
    cell.selectedBackgroundView = testView2;
    ......
}

這樣基本就OK了。

    我在另一個(gè)文章里看到的方法確實(shí)通過自己寫代碼來實(shí)現(xiàn)大部分功能我覺得相對(duì)比較好但是很多陰影效果還是需要在研究研究的。主要是修改custom cell的setFrame,和修改tableview的

willDisplayCell來看看這兩段代碼

//custom 重寫setFrame方法當(dāng)然該方法最好針對(duì)iOS7才有效。

#define IOS7_OR_LATER   ( [[[UIDevice currentDevice] systemVersion] compare:@"7.0"] != NSOrderedAscending )
- (void)setFrame:(CGRect)frame {
    if (IOS7_OR_LATER) {
        NSInteger inset = 10;
        frame.origin.x += inset;
        frame.size.width -= 2 * inset;
    }
    [super setFrame:frame];
}

然后寫UITableViewDelegate的回調(diào)函數(shù)

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if ([cell respondsToSelector:@selector(tintColor)]) {
        if (tableView == self.vTableView) {
            CGFloat cornerRadius = 10.f;
            cell.backgroundColor = UIColor.clearColor;
            CAShapeLayer *layer = [[CAShapeLayer alloc] init];
            CAShapeLayer *borderLayer = [[CAShapeLayer alloc] init];
            CAShapeLayer *selectedLayer = [[CAShapeLayer alloc] init];
                           
            CGMutablePathRef borderPathRef = CGPathCreateMutable();
            CGRect bounds0 = CGRectInset(cell.bounds, 0, 0);
            NSLog(@"bound0:%@",NSStringFromCGRect(cell.frame));
            if (indexPath.row == 0 && indexPath.row == [tableView numberOfRowsInSection:indexPath.section]-1) {
                CGPathAddRoundedRect(borderPathRef, nil, bounds0, cornerRadius, cornerRadius);
            } else if (indexPath.row == 0) {
                CGPathMoveToPoint(borderPathRef, nil, CGRectGetMinX(bounds0), CGRectGetMaxY(bounds0));//left bottom
                CGPathAddArcToPoint(borderPathRef, nil, CGRectGetMinX(bounds0), CGRectGetMinY(bounds0), CGRectGetMidX(bounds0), CGRectGetMinY(bounds0), cornerRadius);
                CGPathAddArcToPoint(borderPathRef, nil, CGRectGetMaxX(bounds0), CGRectGetMinY(bounds0), CGRectGetMaxX(bounds0), CGRectGetMidY(bounds0), cornerRadius);
                CGPathAddLineToPoint(borderPathRef, nil, CGRectGetMaxX(bounds0), CGRectGetMaxY(bounds0));
            } else if (indexPath.row == [tableView numberOfRowsInSection:indexPath.section]-1) {
                CGPathMoveToPoint(borderPathRef, nil, CGRectGetMinX(bounds0), CGRectGetMinY(bounds0));//left top
                CGPathAddArcToPoint(borderPathRef, nil, CGRectGetMinX(bounds0), CGRectGetMaxY(bounds0), CGRectGetMidX(bounds0), CGRectGetMaxY(bounds0), cornerRadius);
                CGPathAddArcToPoint(borderPathRef, nil, CGRectGetMaxX(bounds0), CGRectGetMaxY(bounds0), CGRectGetMaxX(bounds0), CGRectGetMidY(bounds0), cornerRadius);
                CGPathAddLineToPoint(borderPathRef, nil, CGRectGetMaxX(bounds0), CGRectGetMinY(bounds0));
            } else {
                CGPathAddRect(borderPathRef, nil, CGRectInset(cell.bounds, 0, 1));
            }
            borderLayer.path = borderPathRef;
            CFRelease(borderPathRef);
            cornerRadius = 7.f;
            CGMutablePathRef pathRef = CGPathCreateMutable();
            CGRect bounds = CGRectInset(cell.bounds, 1, 1);
            BOOL addLine = NO;
            if (indexPath.row == 0 && indexPath.row == [tableView numberOfRowsInSection:indexPath.section]-1) {
                CGPathAddRoundedRect(pathRef, nil, bounds, cornerRadius, cornerRadius);
            } else if (indexPath.row == 0) {
                CGPathMoveToPoint(pathRef, nil, CGRectGetMinX(bounds), CGRectGetMaxY(bounds0));
                CGPathAddArcToPoint(pathRef, nil, CGRectGetMinX(bounds), CGRectGetMinY(bounds), CGRectGetMidX(bounds), CGRectGetMinY(bounds), cornerRadius);
                CGPathAddArcToPoint(pathRef, nil, CGRectGetMaxX(bounds), CGRectGetMinY(bounds), CGRectGetMaxX(bounds), CGRectGetMidY(bounds), cornerRadius);
                CGPathAddLineToPoint(pathRef, nil, CGRectGetMaxX(bounds), CGRectGetMaxY(bounds0));
                addLine = YES;
            } else if (indexPath.row == [tableView numberOfRowsInSection:indexPath.section]-1) {
                CGPathMoveToPoint(pathRef, nil, CGRectGetMinX(bounds), CGRectGetMinY(bounds0));
                CGPathAddArcToPoint(pathRef, nil, CGRectGetMinX(bounds), CGRectGetMaxY(bounds), CGRectGetMidX(bounds), CGRectGetMaxY(bounds), cornerRadius);
                CGPathAddArcToPoint(pathRef, nil, CGRectGetMaxX(bounds), CGRectGetMaxY(bounds), CGRectGetMaxX(bounds), CGRectGetMidY(bounds), cornerRadius);
                CGPathAddLineToPoint(pathRef, nil, CGRectGetMaxX(bounds), CGRectGetMinY(bounds0));
            } else {
                CGPathAddRect(pathRef, nil, CGRectInset(cell.bounds, 1, 0));
                addLine = YES;
            }
            layer.path = pathRef;
            selectedLayer.path = pathRef;
            CFRelease(pathRef);
            layer.fillColor = [UIColor whiteColor].CGColor;
            selectedLayer.fillColor = [UIColor redColor].CGColor;
                           
            borderLayer.zPosition = 0.0f;
            borderLayer.strokeColor = [UIColor blueColor].CGColor;
            borderLayer.lineWidth = 1;
            borderLayer.lineCap = kCALineCapRound;
            borderLayer.lineJoin = kCALineJoinRound;
                           
            [borderLayer addSublayer:layer];
                           
            if (addLine == YES) {
                CALayer *lineLayer = [[CALayer alloc] init];
                CGFloat lineHeight = (1.f / [UIScreen mainScreen].scale);
                lineLayer.frame = CGRectMake(CGRectGetMinX(bounds)+1, bounds0.size.height-lineHeight, bounds0.size.width-2, lineHeight);
                lineLayer.backgroundColor = tableView.separatorColor.CGColor;
                [layer addSublayer:lineLayer];
            }
            //add general view
            UIView *testView = [[UIView alloc] initWithFrame:bounds];
            [testView.layer insertSublayer:borderLayer atIndex:0];
            testView.backgroundColor = UIColor.clearColor;
            cell.backgroundView = testView;
                           
            //add selected layer view;
            UIView *testView2 = [[UIView alloc] initWithFrame:bounds];
            [testView2.layer insertSublayer:selectedLayer atIndex:0];
            testView2.backgroundColor = UIColor.clearColor;
            cell.selectedBackgroundView = testView2;
        }
    }
}

代碼至此結(jié)束看看最終的效果圖吧

iOS7 UITableView做成類似iOS6風(fēng)格

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。

分享文章:iOS7UITableView做成類似iOS6風(fēng)格-創(chuàng)新互聯(lián)
分享網(wǎng)址:http://www.chinadenli.net/article0/djogio.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供電子商務(wù)微信公眾號(hào)網(wǎng)站維護(hù)定制網(wǎng)站響應(yīng)式網(wǎng)站網(wǎng)站建設(shè)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

手機(jī)網(wǎng)站建設(shè)