荣耀彩票代理

  • 热门专题

半糖iOS版荣耀彩票代理实现与基本理揭秘

作者:  发布日期:2016-12-26 20:23:33
  • HENJIUYIQIAN,YIGEXUEDIDECENGWENGUOWORUHESHIXIANBANTANGiOSBANBENRONGYAOCAIPIAODAILIXIAOGUO,WODANGSHIYIKANJUEDEZHEIGEXIAOGUOTINGKUXUAN,RANHOUQUgithubSHANGSOULEYIXIA,HENDUOZICHENGSHIFANGBANTANGRONGYAOCAIPIAODAILIDE,WOXIAZAIZHIHOUFAXIANQISHIHENDUODAIMADOUMEIYOUSHIXIANZHUYAODEDAIMA。YOUXIEDAIMAYEZUOLEYIXIEJIANDANDECHANGSHI,DANSHIZUIHOUDOUFANGQILE,SUOYISHUOZHEIGEXIAOGUOHAISHIMEIYOUHENHAODESHIXIAN。WOYUSHIDASUANYANJIUYIXIAZHEIGEYOUQUDEXIAOGUO,JINGGUOGONGZUOZHIYUYIDUANSHIJIANDEYANJIU。YOUSHIHOULUSHANGYEHUIXIANGYIXIANG,ZUOLEHENDUODECHANGSHI,YIDIANYIDIANDEBAYUDAODEWENTIJIEJUELE。YUSHIXIEXIAZHEIPIANWENZHANG,BAZIJIDEYIXIECHANGSHIHEXIANGFAYUDAJIAFENXIANG。

    荣耀彩票代理YOUDEKAIFAZHEKENENGHUIJUEDEZHEIMEJIANDANDEDONGXIBIENALAIHUYOUWO,KEYIZIJIQINZICHANGSHIQUZUOYIGE,BINGMEIYOUXIANGXIANGDENEIMEJIANDAN。

    实现上滑的的效果

    荣耀彩票代理ZHEIYIBUSHIRONGYAOCAIPIAODAILIXIAOGUODEJICHU,SHIXIANZHEIYIBUHOU,CAIYOUJIXUQITABUDEBIYAO,ZHEILIMIANNANDUBUSHIHENDA,GUANJIANSHIYAOXIANGDAOYIGEHAOFANGFABURONGYI。XIAMIANJIUJUTIJIANGJIANGSHIRUHESHIXIANDE。

    YOUYIDIANKEYIQUEDINGDESHI,SHIYONGDEKENDINGSHIKVODEZUOFA。TONGGUOJIANTINGcontentOffsetDEBIANHUALAIJINXINGXIANGYINGDECHULI。DANSHIJUTIZENMEZUO,ZENMELAIHUAFENCENGCI,ZHENDESHIYIGERANGRENNAOQIAOTONGDEWENTI。

    ZENMEXIASHOUNI,KAISHIZHENDEHAOWUSIXU,RANHOUXIANGDAOLEYIGELIQI,Reveal。BUGUANBIEDE,XIANYONGRevealKANKANTUCENGJIEGOUZAISHUO。GUANYURevealDESHIYONG,ZAIWODELINGWAIYIPIANWENZHANGLIMIANYOU。SHIYONGRevealCHAKANRENYIiOS AppDETUCENGJIEGOU。TONGGUOTUCENGCHAKANHOU,XIAMIANSHIYIGEScrollView,SHANGMIANSHIJIGETableView。YUSHIZHEIGELIKEBAWODAIRULEKENG,HENDUOWANGSHANGDEDemoDOUSHIZHEIYANGCHANGSHI,BATableViewFANGDAOScrollViewSHANGMIAN,RANHOUDUITAMENDEcontentOffsetDOUTIANJIAJIANTING。TONGGUOPANDUANPIANYILIANGLAIJINYONGTableViewHUOSHIScrollewDESHOUSHI。JINGGUOWUSHUCIDECHANGSHIZUIHOUHAISHIFANGQILE,SHOUSHICHONGTUZHEIGEWENTIBUKENENGZHEIYANGHENHAODEJIEJUE。

    荣耀彩票代理RANHOUWOSOULEZILIAO,YOURENSHUOKEYISHIYONGcontentInsetZHEIGESHUXING,ZHEISHIYONGLAISHEDINGScrollViewJIQIZILEIDENEIRONGXIANSHIQUYU,TONGGUOGAIBIANZHEIGESHUXINGDEZHI,DADAOLEISIDEHUADONGDEXIAOGUO。YEJIUSHIZAIKVODESHIXIANFANGFALIMIANBUDUANDEGAIBIANcontentInsetDEZHI,RANHOUMONISHANGTUIDEXIAOGUO。MEIYOUSHIGUOZHEIGESHUXINGDEKEYICHANGSHIYIXIA。WOSHIYONGZHIHOU,CHUXIANDEWENTIJIUSHIKADUN,TEBIEKA,ERQIEHENNANKONGZHIZHI,ZHEIJIUZAOCHENGLEWANQUANMEIYOULIUCHANGXINGKEYAN。JIANJIESHUOMINGLESHIYONGZHEIGEGENBENMEIFADADAOZHEIGEXIAOGUO。

    RANHOUWOSHIZAISHIXIANGBUDAOSHENMEHAOBANFA,DASUANYONGUISwipGesturer,BUGUOXIANGXIANGZHEIJIUSUANLEBA。TAIYUCHUNLE,ERQIEYEHUIHENMAFAN。XIANGWOZHEIYANGLANDE,ZONGXIANGSHAOXIEJIXINGDAIMA。ZENMEBANNI,ZAIXIANGXIANG。YOUYITIANZAIDITIESHANGNACHUBANTANGDEAPPLAIYANJIU,TURANLINGGUANGYISHAN,XIANGDAOLE。YINWEIJIRANZHEIMELIUCHANG,NEIYIDINGSHISHIYONGLEYUANSHENGDEUITableView,RANHOUZAISHIYONGscrollIndicatorInsetsZHEIGESHUXINGJIUKEYIWEIZHUANGCHUtableViewSHICONGXIAMIANKAISHIDEXIAOGUO,RANHOUWODEtableViewCONGZUOBIAO(0,0)DEWEIZHIKAISHI。SHANGMIANTIANJIAYIGEKONGBAIDEViewBANEIRONGWANGXIAMIANCHENGJIKESHIXIANLEISIDEXIAOGUO。RUTU(WEILEBIANYUKANQINGCHUBUJU,WOJIMEIGESHITULIULEYIGEBIANJU)

    这里写图片描述

    NENGXIANGDAOZHEIYIBUQISHIWANCHENGLEHENDADEGONGZUOLE。JIEXIALAIJIUSHIJISHANGMIANDESOUSUOKUANGHELUNBOYEMIANTIANJIAZUOBIAOBIANHUADESHIJIANLE。

    头部三个View的坐标改变

    荣耀彩票代理JITableViewTIANJIAJIANTING,RANHOUZAIRUXIAFANGFALIMIANGENJUcontentOffsetDEZHIGAIBIANLUNBOHEFENLEIXUANZEKONGJIADEZUOBIAO。

     (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSString *,id> *)change context:(void *)context
    {
        UITableView *tableView = (UITableView *)object;
    
        if (![keyPath isEqualToString:@'contentOffset']) {
            [super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
            return;
        }
    
        CGFloat tableViewoffsetY = tableView.contentOffset.y;
        self.lastTableViewOffsetY = tableViewoffsetY;
    
        if ( tableViewoffsetY>=0 && tableViewoffsetY<=136) {
            self.segmentScrollView.frame = CGRectMake(0, 200tableViewoffsetY, SCREEN_WIDTH, 40);
            self.cycleScrollView.frame = CGRectMake(0, 0tableViewoffsetY, SCREEN_WIDTH, 200); 
        }else if( tableViewoffsetY < 0){
            self.segmentScrollView.frame = CGRectMake(0, 200, SCREEN_WIDTH, 40);
            self.cycleScrollView.frame = CGRectMake(0, 0, SCREEN_WIDTH, 200);
    
        }else if (tableViewoffsetY > 136){
            self.segmentScrollView.frame = CGRectMake(0, 64, SCREEN_WIDTH, 40);
            self.cycleScrollView.frame = CGRectMake(0, 136, SCREEN_WIDTH, 200);
        }
    }
    

    荣耀彩票代理WOMENXUYAOTIANJIAYIGEZUOBIAODEXIANZHI,YINWEIPIANYILIANGYOUSHIHOUHUIWUXIANDAHUOZHESHIWUXIANXIAO。ERWOMENDELUNBOHEFENLEIXUANZEQIDEQUJIANSHIGUDINGBUBIANDE。SUOYIXUYAOZHAODUIZUOBIAOJINXINGXIANZHI,YIDANPIANYILIANGCHAOGUOLEZHEIGEZUOBIAOJIUBUJINXINGGAIBIAN,ERSHIBAOCHIGUDINGDEZHIBUBIAN。

    WEILEMOKUAIDEHUAFENQINGXIYIXIE,WOBASHANGMIANDESOUSUKUANGDANDUDEHUAFENDAOLEJQHeaderViewLIMIAN。SUOYIXUYAOBAWAIMIANDEtableViewCHUANDAOLIMIANQU。RANHOUZAILIMIANTONGYANGJINXINGLEJIANTINGRANHOUSHIJIANCHULI。

     (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
    {
    
        if (![keyPath isEqualToString:@'contentOffset']) {
            [super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
            return;
        }
        UITableView *tableView = (UITableView *)object;
        CGFloat tableViewoffsetY = tableView.contentOffset.y;
    
        UIColor * color = [UIColor whiteColor];
        CGFloat alpha = MIN(1, tableViewoffsetY/136);
    
        self.backgroundColor = [color colorWithAlphaComponent:alpha];
    
        if (tableViewoffsetY < 125){
    
            [UIView animateWithDuration:0.25 animations:^{
                self.searchButton.hidden = NO;
                [self.emailButton setBackgroundImage:[UIImage imageNamed:@'home_email_black'] forState:UIControlStateNormal];
                self.searchBar.frame = CGRectMake((self.width60), 30, self.width80, 30);
                self.emailButton.alpha = 1alpha;
                self.searchButton.alpha = 1alpha;
    
    
            }];
        } else if (tableViewoffsetY >= 125){
    
            [UIView animateWithDuration:0.25 animations:^{
                self.searchBar.frame = CGRectMake(20, 30, self.width80, 30);
                self.searchButton.hidden = YES;
                self.emailButton.alpha = 1;
                [self.emailButton setBackgroundImage:[UIImage imageNamed:@'home_email_red'] forState:UIControlStateNormal];
            }];
        }
    
    }

    ZUOWANYISHANGGONGZUOHOU,WOMENYINGGAIKEYIKANDAODESHIZHEIYANGDEXIAOGUO。

    这里写图片描述


    添加下拉刷新的文字效果

    荣耀彩票代理XIALASHUAXINWODANDUFENLICHULAILEJQRefreshHeaaderWENJIAN。SHIXIANDEYUANLIYIYANGSHIYONGLEKVO。SHIYONGPIANYILIANGJINXINGXIANGYINGDETUPIANTIHUAN,ZAIMOUGEPIANYILIANGKAISHICHUXIANTUPIAN,ZAILINGYIGEPIANYILIANGJIESHU。ZHEIZHONGJIANMEILIANGGEXIANGSUDEPIANYILIANGTIHUANWEIYIZHANGTUPIAN, RANHOUYINZANGQITASUOYOUDETUPIAN,JIUXIANSHIDANGQIANDETUPIAN,DANGPIANYILIANGDEJUEDUIZHIDAYUMOUGEZHISHI,XIANSHISUOYOUDETUPIAN,XIAOYUMOUGEZHISHIYINZANGSUOYOUDETUPIAN。DANGRANZHEILIMIANHAIZHIDETUIQIAO,GANJUEKEYIJIANHUAYIXIEBUZHOU,

     (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
    {
    
    
        if (![keyPath isEqualToString:@'contentOffset']) {
            [super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
            return;
        }
    
        UITableView *tableView = (UITableView *)object;
        CGFloat tableViewoffsetY = tableView.contentOffset.y;
    
        if ( tableViewoffsetY <= 0  &&tableViewoffsetY > 35) {
    
            [self hideAllImageView];
    
        }else if(tableViewoffsetY < 35){
    
            if (tableViewoffsetY < 59) {
    
                [self showAllImageView];
            }else {
                CGFloat offset = fabs(tableViewoffsetY)35;
                NSInteger imageCount = offset/2.0;//两个偏移量切换一张图片
                [self hideImageViewExcept:imageCount];
            }
    
        }else if (tableViewoffsetY <136){
    
        }
    
    }
    

    把这里面使用的图片是我自己用PS做的,所以看起来很丑,实现后的效果如下
    这里写图片描述

    添加分类滑动

    SHOUXIANSHIDANCHUNDESHIXIANZUOYOUHUADONGDEXIAOGUO,ZHEILIWOSHIYONGLEJIANDANDEScrollViewLAISHIXIANZHEIGEXIAOGUO。SHANGMIANDEFENLEIXUANZESHIYIGEScrollView,XIAMIANDEYESHIScrlloView,ZAIQIEHUANSHIHOUXIUGAIDUIYINGDEPIANYILIANGJIKE。DANGRANSHIXIANFANGSHIHENDUO,WANGSHANGYEYOUHENDUODEKUANGJIA,BUGUOGAIXIANGMUDEFENLEIXUANZEKONGJIANXUYAOSHIXIANSHANGXIAHUADONG,SUOYIWOHAISHIZIJISHIXIANLE。SHIXIANYUANLIHENJIANDAN

    荣耀彩票代理SHOUXIANSHIDIANJISHANGMIANDEFENLEIKONGJIANSHIXIANXIAMIANScrollViewDEHUADONG。WOMENZHIXUYAOZAIGAIBIANGAIBIANFENLEIKONGJIANPIANYILIANGDETONGSHIGAIBIANXIAMIANNEIRONGScrollViewDEPIANYILIANG

     [UIView animateWithDuration:0.3 animations:^{
            if (index == 0) {
                self.currentSelectedItemImageView.frame = CGRectMake(PADDING, self.segmentScrollView.frame.size.height  2,currentButton.frame.size.width, 2);
    
            }else{
    
                UIButton *preButton = self.titleButtons[index  1];
    
                float offsetX = CGRectGetMinX(preButton.frame)PADDING*2;
    
                [self.segmentScrollView scrollRectToVisible:CGRectMake(offsetX, 0, self.segmentScrollView.frame.size.width, self.segmentScrollView.frame.size.height) animated:YES];
    
                self.currentSelectedItemImageView.frame = CGRectMake(CGRectGetMinX(currentButton.frame), self.segmentScrollView.frame.size.height2, currentButton.frame.size.width, 2);
            }
            self.bottomScrollView.contentOffset = CGPointMake(SCREEN_WIDTH *index, 0);
    
        }];
    

    荣耀彩票代理RANHOUMENZAIHUADONGXIAMIANDEScrollViewDESHIHOUHUADONGZAIDAILIFANGFALIMIANFENLEIXUANZEKONGJIANYEGENZHEJINXINGHUADONGJIKE。

        [UIView animateWithDuration:0.3 animations:^{
            if (index == 0) {
                self.currentSelectedItemImageView.frame = CGRectMake(PADDING, self.segmentScrollView.frame.size.height  2,currentButton.frame.size.width, 2);
    
            }else{
    
    
                UIButton *preButton = self.titleButtons[index  1];
    
                float offsetX = CGRectGetMinX(preButton.frame)PADDING*2;
    
                [self.segmentScrollView scrollRectToVisible:CGRectMake(offsetX, 0, self.segmentScrollView.frame.size.width, self.segmentScrollView.frame.size.height) animated:YES];
    
                self.currentSelectedItemImageView.frame = CGRectMake(CGRectGetMinX(currentButton.frame), self.segmentScrollView.frame.size.height2, currentButton.frame.size.width, 2);
            }
    
        }];
    
    

    荣耀彩票代理ZHEIYANGJIANDANSHIXIANDEHUADONGKONGJIANKENDINGYOUHENDUOZHIDEYOUHUADEDIFANG,ZUIJIANDANYOUHUAJIUSHIBAXIAMIANDEUIScrollViewHUANCHENGUICollectionView,ZHEIYANGJIUKEYIFUYONGCellCONGERYOUHUANEICUN。

    实现后的基本效果如下
    这里写图片描述

    为分类滑动添加上下滑动的交互

    荣耀彩票代理DAOZHEIYIBUGANJUEZHEIYESHIYIJIANFEICHANGFEINAOZIDESHIQING,MEIYIGEFENLEIDOUYAONENGHUADONGSHANGMIANDEFENLEIKONGJIANHETUIJIANKONGJIAN,ERQIEZAIHUADONGDAORENYIWEIZHIZHIHOU,QIEHUANFENLEIHOUHAIXUYAONENGGOUJIXUHUADONGSHITU。

    荣耀彩票代理SHOUXIANWOMENLAIJIEJUEDIYIGEWENTI,RUHERANGSUOYOUDEFENLEIDOUKEYIYOULEISIDEXIAOGUONI。QISHIHENJIANDAN,NONGYIGESHUZU,BASUOYOUDEKONGZHIQILIMIANDETableViewFANGDAOLIMIANQU,RANHOUJISUOYOUDETableViewDEcontentOffsetDOUTIANJIAKVOJIUHAOLE。DANGRANJIBENSILUJIUSHIZHEIYANG,JUTISHIJIANDESHIHOUKENENGHUIYUDAOHENDUODEWENTI,DUZHEKEYIZIXINGCHANGSHIYANJIU。DANGRANWOMENDEXIALASHUAXINKONGJIANYEXUYAOTIANJIADAOMEIYIGEtableViewSHANGMIAN

    for (int i = 0; i<CATEGORY.count; i++) {
    
                JSDTableViewController *jsdTableViewController = [[JSDTableViewController alloc] init];
                jsdTableViewController.view.frame = CGRectMake(SCREEN_WIDTH * i, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
    
                jsdTableViewController.view.backgroundColor = colors[i];
                [self.bottomScrollView addSubview:jsdTableViewController.view];
    
                [self.controlleres addObject:jsdTableViewController];
                [self.tableViews addObject:jsdTableViewController.tableView];
    
                //下拉刷新动画
               JQRefreshHeaader *jqRefreshHeader  = [[JQRefreshHeaader alloc] initWithFrame:CGRectMake(0, 212, SCREEN_WIDTH, 30)];
                jqRefreshHeader.backgroundColor = [UIColor whiteColor];
                jqRefreshHeader.tableView = jsdTableViewController.tableView;
                [jsdTableViewController.tableView.tableHeaderView addSubview:jqRefreshHeader];
    
    
                NSKeyValueObservingOptions options = NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld;
                [jsdTableViewController.tableView addObserver:self forKeyPath:@'contentOffset' options:options context:nil];
    
            }
    

    荣耀彩票代理ZHEIYANGDEHUA,WOZAIQIEHUANZHIHOUQITADEKONGZHIQIYEKEYISHIXIANSHANGHUADEXIAOGUO。BUGUORUGUOWOHUALEYIBUFENMEIYOUDAOZUISHANGMIANHUOSHIZUIXIAMIANDEHUA,JIUHUICHUXIANCUOLUANDEQINGKUANG。YAOBAOCHIGEGEKONGZHIQINENGGOULIANXUHUADONG。WOMENKEYIJILUXIASHANGYICIDEPIANYILIANG,RANHOUZAIQIEHUANDESHIHOUDUIQITADEtableViewYESHEZHITONGYANGDEPIANYILIANG,ZHEIYANGJIUKEYIBAOZHENGDOUBAOCHITONGYIDEPIANYILIANG,DANGRANWOZUOLELEISIBANTANGDEPANDUAN,JIUSHIDANGPIANYILIANGDAYUZUIDAZHIDANGSHIHOUSHEZHIWEIZUIDAZHI,XIAOYUZUIXIAOZHIDESHIHOUSHEZHIWEI0.

    self.currentTableView  = self.tableViews[index];
        for (UITableView *tableView in self.tableViews) {
    
            if ( self.lastTableViewOffsetY>=0 &&  self.lastTableViewOffsetY<=136) {
                tableView.contentOffset = CGPointMake(0,  self.lastTableViewOffsetY);
    
            }else if(  self.lastTableViewOffsetY < 0){
                tableView.contentOffset = CGPointMake(0, 0);
    
            }else if ( self.lastTableViewOffsetY > 136){
                tableView.contentOffset = CGPointMake(0, 136);
            }
    
        }
    
    

    最后实现的效果如下所示,感觉还可以吧。
    这里写图片描述

    最后

    荣耀彩票代理LIMIANDEDIANJISHIJIANWODOUMEIYOUTIANJIA,ZHEIXIEDOUHENJIANDAN。。BUXIANGLANGFEISHIJIANZAIZHEISHANGMIAN。

    荣耀彩票代理GONGCHENGLIMIANDEResourceMULUXIASHIWOZHUABAODAODEYIXIESHUJU,WEILEFANGZHIBANTANGXIUGAIQUANXIANXIAZAIBUDAOTUPIAN,WOBAXUYAODETUPIANDOUTIQIANXIAZAIYIFEN,YIDANXIAZAISHIBAIJIUSHIYONGBENDITUPIAN,HAIYOUYIXIEZIJIDETUPIAN。WEILEFANGBIANDAJIAXUEXISHIYONG,WOMEIYOUBATUPIANWENJIANFANGRUAssets.xcassetsMULUXIA,YINWEIFANGRUZHEILI,DUIYUXUYAOTUPIANXUEXIFUYONGDESHIHOUXUYAOYIZHANGTUPIANYIZHITUPIANKAOBEICHULAI,FEISHIJIANFEILIQI。LIMIANGUANYUBANTANGDESHUJUJINYONGYUJIAOLIUHEXUEXI,RUOYONGYUSHANGYEYONGTU,HOUGUOZIFU。

    荣耀彩票代理RUGUONIBOKEJINILEYIXIEBANGZHU,XIWANGDIANYIBOCSDNDEGUANZHU。ZUIHOUFUSHANGDemoDIZHIJSDBanTangHomeDem,RUGUOJUEDEMANYI,QINGJIGESatr。

About IT165 - 广告服务 - 隐私声明 - 版权申明 - 免责条款 - 网站地图 - 网友投稿 - 联系方式
本站内容来自于互联网,仅供用于网络技术学习,学习中请遵循相关法律法规