【代碼筆記】點擊頂點處,彈出另一個小的界面

来源:http://www.cnblogs.com/yang-guang-girl/archive/2016/01/18/5138362.html
-Advertisement-
Play Games

一,效果圖。二,文件目錄。三,代碼。RootViewController.h#import @interface RootViewController : UIViewController{ UIView * _huiView; UITableView * _btnTableView; ...


一,效果圖。

 

二,文件目錄。

三,代碼。

RootViewController.h

複製代碼
#import <UIKit/UIKit.h>

@interface RootViewController : UIViewController
<UITableViewDataSource,UITableViewDelegate>
{
    UIView * _huiView;
    UITableView * _btnTableView;
    UITableView * _tableView;

}
@end
複製代碼

 

RootViewController.m

複製代碼
#import "RootViewController.h"

@interface RootViewController ()

@end

@implementation RootViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    //初始化背景圖
    [self initBackGroundView];
}
#pragma -mark -functions
-(void)initBackGroundView
{
    //大的tableView
    _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0,90, 320, self.view.bounds.size.height )];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    _tableView.backgroundColor=[UIColor whiteColor];
    [self.view addSubview:_tableView];
    
    
    //點擊單元格時候的UIView
    _huiView = [[UIView alloc] initWithFrame:CGRectMake(-320, 90, 320, self.view.bounds.size.height)];
    _huiView.backgroundColor = [UIColor blueColor];
    _huiView.alpha=0.9;
    _huiView.layer.cornerRadius = 10;
    [self.view addSubview:_huiView];
    
    
    //三角形
    NSString *path = [[NSBundle mainBundle] pathForResource:@"shangwu_shaixuan_sanjiaoxing" ofType:@"png"];
    UIImage *image = [[UIImage alloc] initWithContentsOfFile:path];
    UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
    imageView.frame = CGRectMake(150, 12, 20, 15);
    [_huiView addSubview:imageView];
    
    //紅色的線
    UIView * view = [[UIView alloc] initWithFrame:CGRectMake(10, 27, 300, 3)];
    view.backgroundColor = [UIColor redColor];
    [_huiView addSubview:view];
    
    
    //用於選擇的tableView
    _btnTableView = [[UITableView alloc] initWithFrame:CGRectMake(10, 30,300,200) style:UITableViewStylePlain];
    _btnTableView.delegate = self;
    _btnTableView.dataSource = self;
    _btnTableView.layer.cornerRadius = 10;
    [_huiView addSubview:_btnTableView];

}
#pragma -mark -UITableViewDelegate
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (tableView == _tableView){
        return 100;
    }
    return 50;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (tableView == _tableView){
        return 100;
    }
    return 5;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (tableView == _btnTableView){
        static NSString * cellName = @"cellName";
        UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:cellName];
        if (cell == nil){
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName];
        }
        if (indexPath.row == 0){
            cell.textLabel.text = @"";
            return cell;
            
        }
        cell.textLabel.text = @"美食";
        cell.textLabel.textColor = [UIColor blackColor];
        return cell;
        
    }else {
        
        static NSString * cellName = @"cell";
        UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:cellName];
        if (cell == nil){
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName];
        }
        if (indexPath.row == 0){
            cell.textLabel.text = @"";
            return cell;
            
        }
        cell.textLabel.text = @"鍛煉";
        cell.textLabel.textColor = [UIColor blackColor];
        return cell;
        }
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@"----didSelectRowAtIndexPath----");
    if (tableView==_tableView) {
        [UIView animateWithDuration:0.7 animations:^{
            _huiView.frame = CGRectMake(0, 45+45, 320, self.view.bounds.size.height);
        }];

    }else{
        [UIView animateWithDuration:0.7 animations:^{
            _huiView.frame = CGRectMake(-320, 45+45, 320, self.view.bounds.size.height);
        }];
    }
   
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
複製代碼

 

 

   
您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • calc是單詞calculate的縮寫,是Css3的一個新的長度單位函數,可以使用簡單的數學運算.Firefox要使用-moz-calc()私有屬性,Chrome要使用-webkit-calc()私有屬性,IE9原生支持標準的不帶首碼的寫法,Opera暫還不支持.運算規則可以使用 “+” “-” “...
  • 1 2 3 4 5 男 6 女 7 中國 8 美國 9 13 14 15
  • //格式化functiontimeCon2(obj){ if(obj==""||obj==undefined){ returnfalse; }else{ vartimeHtml=""; vartime=obj; time=time.split(''); varyear=time[2]//年...
  • 效果圖:查看效果:http://hovertree.com/jq/hovertreeimg/下載:http://hovertree.com/h/bjaf/gk8mko69.htm使用代碼: HovertreeImg Home - 何問起 --> ...
  • 前沿 上一篇介紹了NavigationView的主要使用方式,本章主要介紹TextInputLayout的使用方式。 TextInputLayout——EditText懸浮標簽 TextInputLayout主要作為EditText的父容器來使用,不能單獨使用。TextInputLayout解...
  • 【版權所有,轉載請註明出處。】項目關鍵java代碼為,將tv設置為從jni讀取的字元串,這裡的破解內容是直接從apk動態調試修改最終顯示在tv里的字元內容1.工具介紹Apktool,反編譯源碼用Androidstudio+smalidea插件,動態調試用2.準備工作A.配置插件下載插件smalide...
  • Android設備中大多都內置了感測器,這些感測器有些是基於硬體的,有些是基於軟體的。通過感測器,可以監控設備的三維運動、位置,可以推斷用戶的動作,如傾斜、震動、旋轉等,可以監控設備周圍環境的變化等。 在Android平臺中,我們可以通過SensorManager訪問、監聽感測器,並獲取相應...
  • 前沿 Android 從5.0開始引入了Material design元素的設計,這種新的設計語言讓整個安卓的用戶體驗煥然一新,google在Android Design Support Library中封裝了一些重要的material design控制項,在這之前其實github上也已經出現了許多....
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...