标签: uiappearance

UISegmentedControl不尊重为UIControlStateDisabled设置的分隔符图像

我正在使用UIAppearanceiOS 5中的新API来UISegmentedControl定制带有自定义图形的样式.我需要能够在执行期间设置一些段被禁用,但这些UIAppearance方法似乎不允许我为状态设置分频器图像UIControlStateDisabled.

我打电话给:

[[UISegmentedControl appearance] setDividerImage:disabledSelectedImage
                                    forLeftSegmentState:UIControlStateDisabled
                                    rightSegmentState:UIControlStateSelected
                                    barMetrics:UIBarMetricsDefault];
Run Code Online (Sandbox Code Playgroud)

where disabledSelectedImage资源来自此资源的可调整大小的图像:

禁用选择的图像

然而,当我将左段设置为disabled([UISegmentedControl setEnabled:forSegmentAtIndex:])时,结果如下:

UISegmentedControl UI故障

您可以清楚地看到UISegmentedControl默认使用UIControlStateNormal- UIControlStateNormal分频器图像.

我很高兴使用设置背景图像 UIControlStateDisabled

[[UISegmentedControl appearance] setBackgroundImage:disabledImage
                                    forState:UIControlStateDisabled
                                    barMetrics:UIBarMetricsDefault];
Run Code Online (Sandbox Code Playgroud)

(并且在处于禁用状态时尊重我提供的图像)但不是分频器图像.有没有人遇到这个或找到解决方案?

uisegmentedcontrol ios ios5 uiappearance

5
推荐指数
1
解决办法
2507
查看次数

UISegmentedControl和UIAppearance的奇怪行为

我通过app委托中的这些语句设置分段控件的外观.

    [[UISegmentedControl appearance] setBackgroundImage:[[UIImage imageNamed:@"segmentation_normal.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0 , 0, 0)] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
    [[UISegmentedControl appearance] setBackgroundImage:[[UIImage imageNamed:@"segmentation_selected.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0 , 0, 0)] 
        forState:UIControlStateSelected barMetrics:UIBarMetricsDefault];

    [[UISegmentedControl appearance] setDividerImage:[UIImage imageNamed:@"segmentation_divider_NormalNormal.png"]   forLeftSegmentState:UIControlStateNormal rightSegmentState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
    [[UISegmentedControl appearance] setDividerImage:[UIImage imageNamed:@"segmentation_divider_NormalSelected.png"] forLeftSegmentState:UIControlStateNormal rightSegmentState:UIControlStateSelected barMetrics:UIBarMetricsDefault];
    [[UISegmentedControl appearance] setDividerImage:[UIImage imageNamed:@"segmentation_divider_SelectedNormal.png"] forLeftSegmentState:UIControlStateSelected rightSegmentState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
Run Code Online (Sandbox Code Playgroud)

结果很好.当我选择任何段时,背景和分隔线设置正确(当应用程序首次启动时,默认选择订单段).如下所示,当我选择Release段时,一切看起来都很好.

在此输入图像描述

问题是当我离开视图然后回到视图(我存储选定的索引并将其设置在viewDidLoad中以重新选择片段)时,由于某种未知原因,分隔符设置不正确.

在此输入图像描述

如果我点击AZ然后释放,它会纠正自己.仅当视图首次加载且所选段为Release或AZ时,才会出现此错误.选择"顺序"并加载视图时,分隔符始终显示正常.

图像尺寸:分隔线宽2px(所有3个图像尺寸相同),背景宽2 px.

任何想法或指示都会受到高度赞赏,过去10个小时我一直在努力寻找无法获得的解决方案.

uisegmentedcontrol ios uiappearance

5
推荐指数
1
解决办法
2079
查看次数

UIBarButtonItem外观我需要一个例外

在我的application:didFinishLauchginWithOptions:设置我的控件的默认外观.

UIImage *transparentImage = [UIImage imageNamed:@"transparent.png"];

[[UIBarButtonItem appearance]setBackgroundImage:transparentImage 
                                       forState:UIControlStateNormal 
                                     barMetrics:UIBarMetricsDefault];
Run Code Online (Sandbox Code Playgroud)

这对我很有用,因为它为普通的UIBarButtonItem提供了透明的平面外观.然而,UIDocumentInteractionController当你按下没有正确外观的"快速查看"时,会出现一个按钮.

在此输入图像描述

我相信这是我所拥有的唯一一个只是一个图像的barbuttonitem.有没有办法我可以修改这个按钮给它一些对比,所以它看起来不那么难看?甚至原始背景在我的naviagationbar背景下看起来还不错.

iphone objective-c uinavigationbar uikit uiappearance

5
推荐指数
1
解决办法
1091
查看次数

自定义后退按钮出现在UIImagePickerController上

我使用以下代码在我的应用程序中自定义导航栏上的后退按钮:

UIImage *backButton = [[UIImage imageNamed:@"backButton"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
UIImage *backButtonOn = [[UIImage imageNamed:@"backButton_on"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:backButton
                                                  forState:UIControlStateNormal
                                                barMetrics:UIBarMetricsDefault];
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:backButtonOn
                                                  forState:UIControlStateHighlighted
                                                barMetrics:UIBarMetricsDefault];
Run Code Online (Sandbox Code Playgroud)

它工作得很好,除非我呈现UIImagePickerController并在照片库中输入相册,后退按钮也是自定义后退按钮.如何取回图像选择器中的原始后退按钮?

back-button uinavigationbar ios uiappearance

5
推荐指数
2
解决办法
2656
查看次数

使用UIAppearance API自定义UIBarButtonSystemItem的色调颜色

我知道我可以自定义UIBarButtonItem文本

setTitleTextAttributes:forState:
Run Code Online (Sandbox Code Playgroud)

还有一种通过自定义UITabBar图标的方法

setSelectedImageTintColor:
Run Code Online (Sandbox Code Playgroud)

有没有办法自定义a的色调UIBarButtonSystemItem(例如垃圾图标颜色),只是为了拥有一致的用户体验?我找不到任何东西.

如果不可能,我该怎么办?我应该保存图标的颜色修改版本吗?我在哪里可以找到它?修改它最简单的方法是什么?

编辑

澄清一下,它不是UIBarButtonItem我要求的背景颜色,而是图标轮廓的颜色.

编辑

设置色调的颜色会UIBarButtonItem产生按钮组的背景颜色.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];


    [[UINavigationBar appearance] setTintColor:[UIColor greenColor]];

    UIBarButtonItem* trashButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemTrash target:nil action:nil];

    trashButton.tintColor = [UIColor blackColor];
    UIViewController* viewController = [[UIViewController alloc] init];
    UINavigationController* navController = [[UINavigationController alloc] initWithRootViewController:viewController];
    [viewController.navigationItem setRightBarButtonItem:trashButton];

    self.window.rootViewController = navController;
    return YES;
}
Run Code Online (Sandbox Code Playgroud)

产生这个.

编辑2

事实证明,系统图标的轮廓颜色实际上可以通过 …

objective-c uikit uibarbuttonitem ios uiappearance

5
推荐指数
2
解决办法
6946
查看次数

防止UiNavigationBar标题被截断?

我试图在我的ios应用程序中自定义navigationBar标题的外观.这是我目前的代码:

NSMutableDictionary *navigationTitleAttributes = [NSMutableDictionary dictionary];
[navigationTitleAttributes setValue:[UIColor whiteColor] forKey:UITextAttributeTextColor];
[navigationTitleAttributes setValue:[UIColor clearColor] forKey:UITextAttributeTextShadowColor];
[navigationTitleAttributes setValue:[NSValue valueWithUIOffset:UIOffsetMake(0.0, 0.0)] forKey:UITextAttributeTextShadowOffset];
[navigationTitleAttributes setValue:[UIFont fontWithName:@"Calibri" size:30] forKey:UITextAttributeFont];


[[UINavigationBar appearance] setTitleTextAttributes:navigationTitleAttributes];
[[UINavigationBar appearance] setTitleVerticalPositionAdjustment:-8 forBarMetrics:UIBarMetricsDefault];
Run Code Online (Sandbox Code Playgroud)

该代码产生以下效果:

截图

它的效果很好但是我的标题从底部被切断了.

我已经看到使用自定义UIView的问题的解决方案(例如这一个:使用titleTextAttributes时,UINavigationbar标题被截断).但是,该特定解决方案要求为每个屏幕更新导航栏的titleView属性.

我想知道是否有一个简单的解决方案可以级联我的整个应用程序.

谢谢

uinavigationbar ios uiappearance

5
推荐指数
1
解决办法
1693
查看次数

去饱和实时UIView层(不是UIImageView)

我想知道什么是去饱和UIView的最佳方法 - 尤其是应用了自定义外观的UISliderView.在iOS 7中,当另一个视图出现在它们上方时,标准控件淡出其色调颜色(例如,共享表或UIAlertView),但由于我是从UIImages构建的,因此色调属性不适用于它,并且它们仍然存在饱和.有没有一种好的,简单的方法去减少这种情况,而不是重新应用新的UIAppearance呢?(如果我去那条路,我是否能够设置从彩色图像到灰度图像的过渡动画?)

提前致谢!

tint uiview ios uiappearance

5
推荐指数
0
解决办法
361
查看次数

tvos:UITextView焦点外观像电影App

我正在构建一个tvos应用程序,我希望UITextView的行为类似于tvos电影应用程序.我对专注的外表特别感兴趣.请看看这两张照片.正常图像

聚焦TextView

目前我只是在聚焦时为textview添加背景颜色,但是如何在附加图像中实现这种聚焦外观.这是我的小代码

override func didUpdateFocusInContext(context: UIFocusUpdateContext, withAnimationCoordinator coordinator: UIFocusAnimationCoordinator) {
        super.didUpdateFocusInContext(context, withAnimationCoordinator: coordinator)
        if context.previouslyFocusedView == lessonDescriptionTxt {

            coordinator.addCoordinatedAnimations({ () -> Void in
                self.lessonDescriptionTxt.layer.backgroundColor = UIColor.clearColor().CGColor

                }, completion: nil)
        }
        if context.nextFocusedView == lessonDescriptionTxt {

            coordinator.addCoordinatedAnimations({ () -> Void in
                self.lessonDescriptionTxt.layer.backgroundColor = UIColor.blackColor().colorWithAlphaComponent(0.2).CGColor

                }, completion: nil)
        }
    }
Run Code Online (Sandbox Code Playgroud)

此外,如果有人可以建议如何在有更多文本时在textView中实现此更多功能.我也读过这个问题让UILabel可以集中精力和可点击(tvOS),但这对我来说不起作用.

uitextview uilabel uiappearance tvos

5
推荐指数
1
解决办法
785
查看次数

UIAabel在UIActivityViewController中的UIAppearance

我有这个代码,UILabel当它们出现在UIAlertControllers中时会改变s 的外观:

UILabel *appearanceLabel = [UILabel appearanceWhenContainedInInstancesOfClasses:@[[UIAlertController class]]];
    [appearanceLabel setAppearanceFont:kFontRegular(18)];
Run Code Online (Sandbox Code Playgroud)

但这也会影响出现在UIActivityViewControllers中的UILabels .

在此输入图像描述

如何排除UILabels UIActivityViewController

uilabel ios uiappearance uialertcontroller

5
推荐指数
1
解决办法
729
查看次数

UIViewController外观

是否可以为UIViewController子类设置外观?

我想要像这样的变量

dynamic open var doneButtonColor: UIColor?
Run Code Online (Sandbox Code Playgroud)

UIViewController子类中,并设置其样式如下:

UIViewControllerSubclass.appearance().doneButtonColor = UIColor.green
Run Code Online (Sandbox Code Playgroud)

ios uiappearance swift

5
推荐指数
0
解决办法
883
查看次数