• UIPickerView自定义背景


    #import <UIKit/UIKit.h>


    @interface MyPicker : UIPickerView {

    }

    @end

    --------------------------------------------------------------------------------

    //
    //  MyPicker.m
    //  PickerSkinTest
    //
    //  Created by Wang WenHui on 10-5-3.
    //  Copyright 2010 __MyCompanyName__. All rights reserved.
    //

    #import "MyPicker.h"
    #import "Function.h"


    @implementation MyPicker


    - (id)initWithFrame:(CGRect)frame {
        if (self = [super initWithFrame:frame]) {
            // Initialization code
            
        }
        return self;
    }


    - (void)drawRect:(CGRect)rect {
        
        //改变最外层的背景
        UIView *v0 = [[self subviews] objectAtIndex:0 ];
        v0.backgroundColor = [Function colorWithHexString:@"#f5f5f5"];
        
        //去掉最大的框
        UIView *v8 = [[self subviews] objectAtIndex:8];
        v8.alpha = 0.0;
        
        //第一列的设置--------------------------------
        UIView *v1 = [[self subviews] objectAtIndex:1 ];
        v1.alpha = 0.6;
        UIView *v2 = [[self subviews] objectAtIndex:2 ];
        v2.alpha = 0;
        UIView *v3 = [[self subviews] objectAtIndex:3 ];
        v3.alpha = 0;
        UIView *v4 = [[self subviews] objectAtIndex:4 ];
        v4.backgroundColor = [Function colorWithHexString:@"#eae1d8"];
        UIView *v5 = [[self subviews] objectAtIndex:5 ];
        v5.alpha = 0.0;
        UIView *v6 = [[self subviews] objectAtIndex:6 ];
        v6.alpha=0.6;
        
        [self setNeedsDisplay];
        
    }


    @end

    ======================================================

    如果是两列的就用下面这个

    - (void)drawRect:(CGRect)rect {
        
        //改变最外层的背景
        UIView *v0 = [[self subviews] objectAtIndex:0 ];
        v0.backgroundColor = [Function colorWithHexString:@"#f5f5f5"];
        
        //去掉最大的框
        UIView *v14 = [[self subviews] objectAtIndex:14];
        v14.alpha = 0.0;
        
        //第一列的设置--------------------------------
        UIView *v1 = [[self subviews] objectAtIndex:1 ];
        v1.alpha = 0.6;
        UIView *v2 = [[self subviews] objectAtIndex:2 ];
        v2.alpha = 0;
        UIView *v3 = [[self subviews] objectAtIndex:3 ];
        v3.alpha = 0;
        UIView *v4 = [[self subviews] objectAtIndex:4 ];
        v4.backgroundColor = [Function colorWithHexString:@"#eae1d8"];
        UIView *v5 = [[self subviews] objectAtIndex:5 ];
        v5.alpha = 0.0;
        UIView *v6 = [[self subviews] objectAtIndex:6 ];
        v6.alpha=0.6;
        
        
        //第二列的设置--------------------------------
        UIView *v7 = [[self subviews] objectAtIndex:7 ];
        v7.alpha = 0.6;
        UIView *v8 = [[self subviews] objectAtIndex:8 ];
        v8.alpha = 0;
        UIView *v9 = [[self subviews] objectAtIndex:9 ];
        v9.alpha = 0;
        UIView *v10 = [[self subviews] objectAtIndex:10 ];
        v10.backgroundColor = [Function colorWithHexString:@"#eae1d8"];
        UIView *v11 = [[self subviews] objectAtIndex:11 ];
        v11.alpha = 0.0;
        UIView *v12 = [[self subviews] objectAtIndex:12 ];
        v12.alpha=0.6;
        
        [self setNeedsDisplay];
        
    }

  • 相关阅读:
    《Microsoft SQL Server 2008 MDX Step by Step》学习笔记九:导航结构层次
    windows live messenger 2009登录失败,提示“错误代码:81000605”的一个解决办法
    《Microsoft SQL Server 2008 MDX Step by Step》学习笔记七:执行聚合(上)
    Java反编译插件Jdclipse导致Eclipse 3.7.2启动崩溃的解决方法
    关于婚姻,你能事先回答这些问题吗?(来自网络)
    邀月的一些其他随笔索引
    《Microsoft SQL Server 2008 MDX Step by Step》学习笔记十一:计算成员和动态命名集
    一点一滴培养你的领袖气质,要经常自我激励(转自网络)
    Firefox中卸载Java Console
    Jquery.Validate验证CheckBoxList,RadioButtonList,DropDownList是否选中
  • 原文地址:https://www.cnblogs.com/lear/p/3214001.html
Copyright © 2020-2023  润新知