2016-01-09 74 views
0

我使用不支持SVG文件viewBox參數一個C#庫,但沒有它,我把我的圖片切斷,因爲他們不能正確縮放,下面詳細介紹......SVG編輯只顯示XAML中SVG圖像文件的一半?

我想在移動應用程序中使用一些SVG文件,使用xamarin表單平臺和nuget插件。該插件的支持非常有限,所以我不得不手動更改svg文件。當產生了Google+圖像具有以下第一個標籤,但是,當我使用這個文件,我得到了以下錯誤消息:

<svg id="Capa_1" data-name="Capa 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><title>Google_Round</title>< 

的System.Exception:無效的參數,以上下文創建 在CoreGraphics.CGContext .set_Handle(IntPtr value)[0x00010]位於/Users/builder/data/lanes/2377/73229919/source/maccore/src/CoreGraphics/CGContext.cs:161 at CoreGraphics.CGContext..ctor(IntPtr handle,Boolean owns )在CorelDR語句中設置/Users/builder/data/lanes/2377/73229919/source/maccore/src/CoreGraphics/CGContext.cs:141 中的[0x00006] CoreGraphics.CGBitmapContext..ctor(IntPtr data,nint width,nint height,nint bitsPerComponent,nint bytesPerRow,CoreGrap hics.CGColorSpace colorSpace,CGImageAlphaInfo bitmapInfo)[/ PHP,尺寸大小,雙刻度,布爾透明度)[0x0005c]在:0 在SVG.Forms.Plugin.iOS.SvgImageRenderer.OnElementChanged(Xamarin.Forms.Platform.iOS.ElementChangedEventArgs`1 E)[0x0010f]在:0

如果我將第一個標記更改爲已知工作示例中第一個標記的副本,則我具有以下SVG文件。

<?xml version="1.0"?> 
<svg xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://www.w3.org/2000/svg" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" height="300" width="300" version="1.1" fill-opacity="0"> xml:space="preserve"> 
     <path fill="#54534A" d="M2204.344,4414.691v-122.67h81.643h81.642l-1.237,6.804c-0.619,3.505-1.649,10.515-2.474,15.462l-1.443,8.659 
      h-61.438h-61.644v38.141v38.141h54.635h54.635v16.493v16.494h-54.635h-54.635v36.079v36.08h60.613h60.407l1.443,10.515 
      c0.825,5.979,2.062,13.401,2.68,16.493l1.237,5.979h-80.818h-80.612V4414.691z"/> 
    <!-- Various Strokes omitted --> 
    </g> 
    </svg> 

這給了我下面的顯示,否則會是一個完整的G +圖標。我認爲這是因爲我丟失了文件中的viewBox信息。我還能如何包含這些信息以確保我的svg能夠適當擴展,而不會導致插件失敗? Icon Comparison

回答

1

在路徑中設置屬性Stretch="Uniform"並通過邊距控制此路徑。