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];/
编程基础网
本文标题为:使用 UIAppearance 自定义 iOS UIDatepicker
基础教程推荐
猜你喜欢
- 突出显示朗读文本(在 iPhone 的故事书类型应用程序中) 2022-01-01
- 在 Android 模拟器中激活网络位置提供程序? 2022-01-01
- 新的@SystemApi 注解是什么意思,和@hide 有什么区别 2022-01-01
- 我的 UIImageView 的任务 2022-01-01
- 在 appComponent dagger 2 中动态添加测试模块? 2022-01-01
- 如何将多个组件添加到 PickerView? 2022-01-01
- 在 iOS8 中无法获得正确的键盘高度值 2022-01-01
- - (CGRect)convertRect:(CGRect)rect toView:(UIView *)view 如何工作 2022-01-01
- Android:STATE_SELECTED不工作 2022-01-01
- 可可/目标C(OSX不是iOS)从子对象访问父对象 2022-01-01
