我有一个应用程序,它具有整个用户界面的蓝色色调主题.我的初始视图中的导航栏中还有一个嵌入式搜索栏.我的应用程序的按钮文本颜色为白色,并在应用程序委托中声明:
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
Run Code Online (Sandbox Code Playgroud)
问题是,由于影响搜索栏的白色调,这会导致嵌入式搜索栏在选中时隐藏光标.我试图使用两种方法专门将搜索栏的色调设置为[UIColor blueColor],但没有运气.我试图引用UISearch栏的两种方式是:
[self.navigationController.searchDisplayController.searchBar setTintColor:[UIColor blueColor]];
Run Code Online (Sandbox Code Playgroud)
和
[searchBar setTintColor:[UIColor blueColor]]
Run Code Online (Sandbox Code Playgroud)
应该正确引用searchBar.
我对这些网点所做的一切都不会影响嵌入式搜索栏.
我的代码与问题相关:
注释.h文件
#import <Foundation/Foundation.h>
#import <MapKit/MapKit.h>
@interface CityAnnotation : NSObject <MKAnnotation> {
NSString *name;
NSString *country;
CLLocationCoordinate2D coords;
}
@property (nonatomic,copy) NSString *name;
@property (nonatomic,copy) NSString *country;
@property (nonatomic,assign) CLLocationCoordinate2D coords;
-(id)initWithTitle:(NSString *)cityname AndCountry:(NSString *)countryname AndCoords: (CLLocationCoordinate2D)coordinate;
@end
Run Code Online (Sandbox Code Playgroud)
注释.m文件
#import "CityAnnotation.h"
@implementation CityAnnotation
@synthesize name,country,coords;
-(id)initWithTitle:(NSString *)cityname AndCountry:(NSString *)countryname AndCoords:(CLLocationCoordinate2D)coordinate
{
self = [super init];
if (self){
self.name = cityname;
self.country = countryname;
self.coords = coordinate;
}
return self;
}
@end
Run Code Online (Sandbox Code Playgroud)
我导入到我的mapview:
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
#import "tableViewController.h"
#import "City.h" …Run Code Online (Sandbox Code Playgroud)