からフェード アニメーションを削除しようとしていCATiledLayer
ます。
このクローズドバグレポートによると、静的プロパティの設定CATiledLayer.FadeDuration
は機能せず、機能することは想定されていません: https://bugzilla.novell.com/show_bug.cgi?id=648993
Objective-C で推奨される解決策は、サブクラス化することCATiledLayer
です: How to change iphone CATiledLayer fadeDuration? . これを MonoTouch に実装しましたが、DrawInContext
期待どおりに呼び出されますが、ビューには何も描画されません。
問題を再現するための完全なコードを以下に示します。すべてを削除するとすぐに機能[Export("fadeDuration")]
します(ただし、アニメーションはあります)。
助けてくれてありがとう。
using System;
using System.Drawing;
using MonoTouch.CoreAnimation;
using MonoTouch.UIKit;
using MonoTouch.Foundation;
using MonoTouch.ObjCRuntime;
[Register("NoFadeTiledLayer")]
public class NoFadeTiledLayer : CATiledLayer {
public NoFadeTiledLayer () : base() {}
public NoFadeTiledLayer (IntPtr handle) : base(handle) {}
public override void DrawInContext (MonoTouch.CoreGraphics.CGContext ctx) {
// This is being called everytime
base.DrawInContext (ctx);
}
[Export("fadeDuration")]
public static new double FadeDuration () {
return 0;
}
}
public class ContentView : UIView {
[Export("layerClass")]
public static Class LayerClass () {
return new Class (typeof(NoFadeTiledLayer));
}
public override void Draw (RectangleF rect) {
DrawString ("Lorem ipsum", rect, UIFont.SystemFontOfSize (15));
}
}
[Register("AppDelegate")]
public class AppDelegate : UIApplicationDelegate {
static void Main (string[] args) {
UIApplication.Main (args, null, "AppDelegate");
}
public override bool FinishedLaunching (UIApplication app, NSDictionary options) {
var window = new UIWindow (UIScreen.MainScreen.ApplicationFrame);
window.BackgroundColor = UIColor.Green;
var view = new ContentView ();
view.BackgroundColor = UIColor.White;
view.Frame = window.Bounds;
window.AddSubview (view);
window.MakeKeyAndVisible ();
return true;
}
}