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];
}
UIPickerView自定义背景的更多相关文章
- 制作自定义背景Button按钮、自定义形状Button的全攻略(转)
在Android开发应用中,默认的Button是由系统渲染和管理大小的.而我们看到的成功的移动应用,都是有着酷炫的外观和使用体验的.因此,我们在开发产品的时候,需要对默认按钮进行美化.在本篇里,笔者结 ...
- listview自定义背景以及item自定义背景
item向自定义背景,可以根据position来设置不同的背景. listview背景设置是需要注意设置下面这几项: //点下时整个页面的背景 android:cacheColorHint=" ...
- Android-重新包装Toast,自定义背景
Android-重新包装Toast,自定义背景 2016-4-27 Android L 算是包装了一个自己使用的小工具. 使用Toast的目的是弹一个提示框.先看一下Toast.makeText方法. ...
- vscode自定义背景颜色
vscode自定义背景颜色 大概做前端的builder(只会打代码的才是coder,嘻嘻~)一半以上都会使用vscode编辑代码吧,vscode很轻量,支持的文件拖拽加入编辑区功能我个人认为很方便 ...
- IOS第11天(2:UIPickerView自定义国旗选择)
国旗选择 #import "HMViewController.h" #import "HMFlag.h" #import "HMFlagView.h& ...
- GUI(自定义背景图片)
如果组件中没有setIcon(...);这个方法,这是有需要给组件设置背景图片,这时就可以自定义绘制背景图片 /** * */ package com.niit.javagui; import jav ...
- UIPickerView去掉背景上的黑线
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger) ...
- UIDatePicker自定义背景
selectDatePicker = [[UIDatePicker alloc]init]; selectDatePicker.frame = CGRectMake(0, 10, 280, 21 ...
- UITabBar实现自定义背景及UITabBarItem自定义图片和字体
UITabBarItem *firstItem = [[UITabBarItem alloc]initWithTitle:]; //设置字体颜色(后面设置字体状态)(UITextAttributeTe ...
随机推荐
- LeetCode Rotate List (链表操作)
题意: 将链表的后面k个剪出来,拼接到前面,比如 1->2->null 变成2->1->null.数字代表一段的意思. 思路: k有3种可能,k>n,k<n,k=n ...
- LeetCode Implement Queue using Stacks (数据结构)
题意: 用栈来实现队列. 思路: 一个栈是不够的,至少要两个. (1)插入.永远只插入到stack1中(插到栈顶). (2)弹出.如果stack2不为空,直接弹出stack2的栈顶,否则,将stack ...
- iptables导致数据包过多时连接失败
前几天做服务器压力测试,本地10个线程不停的去向服务器建立连接,然后请求数据,然后连接再关闭,程序每运行几万次之后就会发现客户端程序没办法connect服务器,connect超时. 一开始怀疑是自己服 ...
- 3des加解密算法
编号:1003时间:2016年4月1日09:51:11功能:openssl_3des加解密算法http://blog.csdn.net/alonesword/article/details/17385 ...
- 我看的公开课系列--《TED:对无知的追求》 by stuart firestein
http://open.sina.com.cn/course/id_1047/ What scientists do is not just collect data and collect fact ...
- Xcode 工程文件打开不出来, cannot be opened because the project file cannot be parsed.
svn更新代码后,打开xcode工程文件,会出现 xxx..xcodeproj cannot be opened because the project file cannot be parsed ...
- discuz如何设置游客可以浏览板块,但是不能查看帖子内容呢?
后台 ,将用户组 --游客 阅读权限设置为0 QQ快捷登陆不正常 ,在首页,点击QQ快捷登陆,并不跳转到QQ认证页面,而是要输入用户名.密码.验证码等. 但是如果输入的是你想新注册的用户名等信息,却不 ...
- 根据评分,用js输出评价星星的样式
<b class="starsboxox" data="1"></b> $('.starsboxox').each(function() ...
- mysql in和or查询效率
http://blog.chinaunix.net/uid-20639775-id-3416737.html 上面链接博主的文章分析结论: or在没有索引的情况下呈指数增长,in则是正常递增. or的 ...
- 关于kafka连接不上别的机器问题Connection refused
1.确认config里面的server.properties 正确(包括IP+端口2181记得看清,用hostname的话记得etc/hostnames下面查看全部配置上没,建议用hostname方便 ...