从iOS 6开始,我在应用程序中使用自定义样式时遇到了一些问题.我使用自定义字体和几个UIAppearance代理.我无法理解的一个问题是UINavigationBar中标题的错位.在iOS 5中,一切正常,并且正确对齐.
由于iOS6已经发布并且自定义样式并不少见,我认为这不是一个bug,而是我对iOS6的一些新变化的误解.

我在文档中搜索了一个文本对齐方法来调用UIAppearance代理,但我无法找到这样的方法.
我使用以下代码行来为我的整个应用程序设置UINavigationBar的样式:
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"NavigationBarBackground"]
forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"NavigationBarBackground"]
forBarMetrics:UIBarMetricsLandscapePhone];
[[UINavigationBar appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor whiteColor], UITextAttributeTextColor,
[UIFont fontWithName:@"Corbel-Bold" size:14.0], UITextAttributeFont,
nil]];
[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setTintColor:[UIColor whiteColor]];
[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor ceBlueColor], UITextAttributeTextColor,
[UIColor whiteColor], UITextAttributeTextShadowColor,
[NSValue valueWithUIOffset:UIOffsetMake(0, 1)], UITextAttributeTextShadowOffset,
[UIFont fontWithName:@"Corbel" size:0.0], UITextAttributeFont,
nil]
forState:UIControlStateNormal];
[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -3) forBarMetrics:UIBarMetricsDefault];
Run Code Online (Sandbox Code Playgroud) 我试过了:
public function up()
{
Schema::create('meetings', function(Blueprint $table) {
$table->increments('id');
$table->string('title');
$table->text('description');
$table->enum('category',[0,1,2,3,4])->index();
$table->unsignedInteger('owner_id');
$table->foreign('owner_id')->references('id')->on('users')->onDelete('cascade');
$table->dateTime('start_date');
$table->dateTime('end_date');
$table->timestamps();
});
DB::raw("ALTER TABLE meetings ADD COLUMN geolocation POINT");
}
Run Code Online (Sandbox Code Playgroud)
但这似乎不起作用.
我喜欢iOS 6中的新自动布局功能,但是当我将它与MKAnnotationView子类结合使用时,我遇到了一些麻烦.
我在初始化方法中禁用了自动调整掩码转换.
self.translatesAutoresizingMaskIntoConstraints = NO;
Run Code Online (Sandbox Code Playgroud)
但是当我加载使用我的子类的注释的MKMapView时,应用程序抛出NSInternalInconsistencyException.
*** Assertion failure in -[ENMapAnnotationView layoutSublayersOfLayer:], /SourceCache/UIKit_Sim/UIKit-2372/UIView.m:5776
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Auto Layout still required after executing -layoutSubviews. ENMapAnnotationView's implementation of -layoutSubviews needs to call super.'
Run Code Online (Sandbox Code Playgroud)
我没有覆盖-layoutSubviews,所以对我看来,Apple的MKAnnotationView实现还没有为自动布局做好准备.有没有一些聪明的方法来解决MKAnnotationView中缺少自动布局支持所以我可以在我的子类中使用自动布局?
ios ×2
autolayout ×1
fonts ×1
geospatial ×1
iphone ×1
laravel ×1
laravel-4 ×1
mapkit ×1
mysql ×1
uiappearance ×1