zoukankan      html  css  js  c++  java
  • UITableView的横向使用

      UITableView只支持竖向显示,要实现横向的显示,需要设置tableView 和cell 的transform属性为CGAffineTransformMakeRotate(-M_PI/2)   

    // 42.5是TableView的高度,320是UITableView的宽度 _tabTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 66, 42.5, 320)]; _tabTableView.dataSource = self; _tabTableView.delegate = self; _tabTableView.showsVerticalScrollIndicator = NO; _tabTableView.separatorStyle = UITableViewCellSeparatorStyleNone; // 设置TableView显示的位置 _tabTableView.center = CGPointMake(320 / 2, 66); _tabTableView.transform = CGAffineTransformMakeRotation(-M_PI_2); [self.view addSubview:_tabTableView];
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
            TabTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"tab"];
            if (cell == nil) {
                cell = [[TabTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"tab"];
            }
            [cell setTitle:_tabArrays[indexPath.row]];
         //这里也要设置一下 cell.transform
    = CGAffineTransformMakeRotation(M_PI_2); return cell; }
    - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
    {
            return 65;//设置横向cell的高度
    }

  • 相关阅读:
    实现随机颜色
    为网站实现一个验证码
    vue.js帐号,密码,邮箱和移动手机号码正则验证
    从网址中截去主机名和参数
    vue.js判断网址参数是否有效
    创建windows service
    vue.js axios call api example
    vue.js mouse over change the image
    jQuery接收url的参数
    ms sql server排序
  • 原文地址:https://www.cnblogs.com/hw140430/p/4355845.html
Copyright © 2011-2022 走看看