使用 UIAppearance 自定义 iOS UIDatepicker

Custom iOS UIDatepicker using UIAppearance(使用 UIAppearance 自定义 iOS UIDatepicker)
本文介绍了使用 UIAppearance 自定义 iOS UIDatepicker的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

如何改变我的 UIDatePicker 的外观?

解决方案

API 没有提供执行此操作的方法.您可以使用 UIPickerView 而不是使用 UIDatePicker 自己制作一个非常令人信服的副本.

由于 UIDatePicker 或 UIPickerView 没有 UI_APPEARANCE_SELECTOR,即使您无法将 UIDatePicker 内容的外观更改为其 UIControl 并且没有任何委托,因此它具有其本机外观,而在 UIPickerView 的情况下,您可以更改其内容'外观类似于 UITableView.

#pragma mark -#pragma mark UIPicker 代表 &数据源- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {返回 2;}//返回每个组件中的行数..- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {返回 100;}//- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent: (NSInteger)component {//return [NSString stringWithFormat:@"%d",row];/
                
本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

Hardware Volume buttons change in app volume(硬件音量按钮更改应用程序音量)
Cocos2d - How to check for Intersection between objects in different layers(Cocos2d - 如何检查不同层中对象之间的交集)
Resume game cocos2d(恢复游戏 cocos2d)
Highlight Read-Along Text (in a storybook type app for iPhone)(突出显示朗读文本(在 iPhone 的故事书类型应用程序中))
Cocos2D + Disabling only Retina iPad Graphics(Cocos2D + 仅禁用 Retina iPad 图形)
Proper cocos2d scene restart?(正确的 cocos2d 场景重启?)