zoukankan      html  css  js  c++  java
  • UITableview自定义accessory按钮和ImageView大小一致

        if (cell == nil) {
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
            cell.accessoryType = UITableViewCellAccessoryDetailButton;
            cell.textLabel.font = [UIFont systemFontOfSize:19.0];
            
            UIImage *image = [UIImage imageNamed:@"england"];
            UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
            CGRect frame = CGRectMake(0.0,0.0,15,15);
            button.frame = frame;
            [button setBackgroundImage:image forState:UIControlStateNormal];
            button.backgroundColor = [UIColor clearColor];
            cell.accessoryView = button;
             [button addTarget:self action:@selector(btnClicked:event:) forControlEvents:UIControlEventTouchUpInside];
        }
    - (void)btnClicked:(id)sender event:(id)event
    {
        NSSet * touches = [event allTouches];
        UITouch * touch = [touches anyObject];
        CGPoint currentTouchPosition = [touch locationInView:self.countriesTableView];
        NSIndexPath * indexPath = [self.countriesTableView indexPathForRowAtPoint:currentTouchPosition];
        if(indexPath != nil)
        {
            [self tableView:self.countriesTableView accessoryButtonTappedForRowWithIndexPath:indexPath];
        }
    }

    设置imageView大小

        cell.imageView.image = [MainTableViewController scale:item.flag toSize:CGSizeMake(115, 75)];
    + (UIImage *)scale:(UIImage *)image toSize:(CGSize)size
    {
        UIGraphicsBeginImageContext(size);
        [image drawInRect:CGRectMake(0, 0, size.width, size.height)];
        UIImage * scaledImage = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();
        return scaledImage;
    }
  • 相关阅读:
    OpenCV 实现图像拼接例子
    XML 可扩展标记语言
    XML和YAML的区别与使用方法
    OpenCV 感兴趣区域ROI和logo添加技术
    OpenCV 详解掩膜mask
    OpenCV 读写xml和yml文件
    OpenCV 如何生成能在无OpenCV环境下运行的exe
    OpenCV 图像拼接和图像融合技术
    OpenCV 特征检测和特征匹配方法汇总
    OpenCV 图像矫正技术深入探讨
  • 原文地址:https://www.cnblogs.com/fengmin/p/5482507.html
Copyright © 2011-2022 走看看