зеркало из https://github.com/xamarin/ios-samples.git
Add new sample
This commit is contained in:
Родитель
a09a2d4958
Коммит
d4cd2e35d4
|
@ -0,0 +1,139 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using MonoTouch.Foundation;
|
||||
using MonoTouch.UIKit;
|
||||
using MonoTouch.Dialog;
|
||||
using System.Drawing;
|
||||
using MonoTouch.CoreText;
|
||||
|
||||
namespace ios7fonts
|
||||
{
|
||||
[Register ("AppDelegate")]
|
||||
public partial class AppDelegate : UIApplicationDelegate
|
||||
{
|
||||
const string lorem =
|
||||
"\nLorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. ";
|
||||
|
||||
DialogViewController dialog;
|
||||
UIFontDescriptor baseline;
|
||||
UIWindow window;
|
||||
|
||||
public Element MakeSample (string text, UIFontDescriptorSymbolicTraits trait)
|
||||
{
|
||||
var font = UIFont.FromDescriptor (baseline.CreateWithTraits (trait), 0);
|
||||
|
||||
return new StyledStringElement (text) { Font = font };
|
||||
}
|
||||
|
||||
public Element MakeMultilineSample (string text, UIFontDescriptorSymbolicTraits trait)
|
||||
{
|
||||
var font = UIFont.FromDescriptor (baseline.CreateWithTraits (trait), 0);
|
||||
|
||||
return new StyledMultilineElement (text) { Font = font };
|
||||
}
|
||||
|
||||
public UIFont ResizeProportionalAndAlternative (UIFont font)
|
||||
{
|
||||
var attributes = new UIFontAttributes (
|
||||
new UIFontFeature (CTFontFeatureNumberSpacing.Selector.ProportionalNumbers),
|
||||
new UIFontFeature ((CTFontFeatureCharacterAlternatives.Selector)1));
|
||||
|
||||
var newDesc = font.FontDescriptor.CreateWithAttributes (attributes);
|
||||
return UIFont.FromDescriptor (newDesc, 40);
|
||||
}
|
||||
|
||||
public UIFont ResizeProportional (UIFont font)
|
||||
{
|
||||
var attributes = new UIFontAttributes (new UIFontFeature (CTFontFeatureNumberSpacing.Selector.ProportionalNumbers));
|
||||
var newDesc = font.FontDescriptor.CreateWithAttributes (attributes);
|
||||
return UIFont.FromDescriptor (newDesc, 40);
|
||||
}
|
||||
|
||||
public UIFont ResizeAlternative (UIFont font)
|
||||
{
|
||||
var attributes = new UIFontAttributes (new UIFontFeature ((CTFontFeatureCharacterAlternatives.Selector)1));
|
||||
var newDesc = font.FontDescriptor.CreateWithAttributes (attributes);
|
||||
return UIFont.FromDescriptor (newDesc, 40);
|
||||
}
|
||||
|
||||
public UIFont Resize (UIFont font)
|
||||
{
|
||||
return UIFont.FromDescriptor (font.FontDescriptor, 40);
|
||||
}
|
||||
|
||||
|
||||
RootElement MakeFonts ()
|
||||
{
|
||||
Console.WriteLine ("Changing");
|
||||
// The baseline to show various adjustments you can make to a font
|
||||
baseline = UIFontDescriptor.PreferredBody;
|
||||
|
||||
return new RootElement ("Fonts") {
|
||||
new Section () {
|
||||
new RootElement ("System Preferred Fonts"){
|
||||
new Section () {
|
||||
new StyledStringElement ("Headline") { Font = UIFont.PreferredHeadline },
|
||||
new StyledStringElement ("Subheadline") { Font = UIFont.PreferredSubheadline },
|
||||
new StyledStringElement ("Body") { Font = UIFont.PreferredBody },
|
||||
new StyledStringElement ("Caption1") { Font = UIFont.PreferredCaption1 },
|
||||
new StyledStringElement ("Caption2") { Font = UIFont.PreferredCaption2 },
|
||||
new StyledStringElement ("Footnote") { Font = UIFont.PreferredFootnote },
|
||||
|
||||
}
|
||||
},
|
||||
new RootElement ("Font weight"){
|
||||
new Section (){
|
||||
MakeSample ("Body Plain", 0),
|
||||
MakeSample ("Body Bold", UIFontDescriptorSymbolicTraits.Bold),
|
||||
MakeSample ("Body Italic", UIFontDescriptorSymbolicTraits.Italic),
|
||||
}
|
||||
},
|
||||
new RootElement ("Line Spacing") {
|
||||
new Section (){
|
||||
MakeMultilineSample ("Line Spacing; regular; " + lorem, 0),
|
||||
MakeMultilineSample ("Line Spacing: tight; " + lorem, UIFontDescriptorSymbolicTraits.TightLeading),
|
||||
MakeMultilineSample ("Line Spacing: loose; " + lorem, UIFontDescriptorSymbolicTraits.LooseLeading),
|
||||
}
|
||||
},
|
||||
new RootElement ("CoreText Font Features"){
|
||||
new Section ("Use Proportional Number") {
|
||||
new StyledStringElement ("10:20") { Font = Resize (UIFont.PreferredBody) },
|
||||
new StyledStringElement ("10:20") { Font = ResizeProportional (UIFont.PreferredBody) },
|
||||
},
|
||||
new Section ("Use Character Alternatives") {
|
||||
new StyledStringElement ("10:20") { Font = Resize (UIFont.PreferredBody) },
|
||||
new StyledStringElement ("10:20") { Font = ResizeAlternative (UIFont.PreferredBody) },
|
||||
},
|
||||
new Section ("Use Proportional + Alternative") {
|
||||
new StyledStringElement ("10:20") { Font = Resize (UIFont.PreferredBody) },
|
||||
new StyledStringElement ("10:20") { Font = ResizeProportionalAndAlternative (UIFont.PreferredBody) },
|
||||
},
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
|
||||
{
|
||||
var fonts = MakeFonts ();
|
||||
window = new UIWindow (UIScreen.MainScreen.Bounds);
|
||||
dialog = new DialogViewController (fonts);
|
||||
var nav = new UINavigationController (dialog);
|
||||
window.RootViewController = nav;
|
||||
window.MakeKeyAndVisible ();
|
||||
|
||||
UIApplication.Notifications.ObserveContentSizeCategoryChanged (delegate {
|
||||
dialog.Root = MakeFonts ();
|
||||
nav.PopToRootViewController (false);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
static void Main (string[] args)
|
||||
{
|
||||
UIApplication.Main (args, null, "AppDelegate");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
</dict>
|
||||
</plist>
|
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>ios7fonts</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.your-company.ios7fonts</string>
|
||||
<key>UIDeviceFamily</key>
|
||||
<array>
|
||||
<integer>1</integer>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>MinimumOSVersion</key>
|
||||
<string>6.0</string>
|
||||
</dict>
|
||||
</plist>
|
|
@ -0,0 +1,6 @@
|
|||
This sample shows how to use many of the new iOS 7 font features in your application
|
||||
and how to customize fonts using UIFontDescriptors.
|
||||
|
||||
Blog post at:
|
||||
|
||||
http://tirania.org/monomac/archive/2013/Sep-25.html
|
|
@ -0,0 +1,102 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">iPhoneSimulator</Platform>
|
||||
<ProductVersion>10.0.0</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{EC8BFD6D-FB32-4895-A962-B659ABE70798}</ProjectGuid>
|
||||
<ProjectTypeGuids>{6BC8ED88-2882-458C-8E55-DFD12B67127B};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>ios7fonts</RootNamespace>
|
||||
<IPhoneResourcePrefix>Resources</IPhoneResourcePrefix>
|
||||
<AssemblyName>ios7fonts</AssemblyName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhoneSimulator' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\iPhoneSimulator\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<MtouchLink>None</MtouchLink>
|
||||
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
|
||||
<MtouchDebug>true</MtouchDebug>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\iPhoneSimulator\Release</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<MtouchLink>None</MtouchLink>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhone' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\iPhone\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
|
||||
<MtouchDebug>true</MtouchDebug>
|
||||
<CodesignKey>iPhone Developer</CodesignKey>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' ">
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\iPhone\Release</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<CodesignKey>iPhone Developer</CodesignKey>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Ad-Hoc|iPhone' ">
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\iPhone\Ad-Hoc</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
|
||||
<BuildIpa>true</BuildIpa>
|
||||
<CodesignProvision>Automatic:AdHoc</CodesignProvision>
|
||||
<CodesignKey>iPhone Distribution</CodesignKey>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'AppStore|iPhone' ">
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\iPhone\AppStore</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodesignKey>iPhone Distribution</CodesignKey>
|
||||
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<CodesignProvision>Automatic:AppStore</CodesignProvision>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="monotouch" />
|
||||
<Reference Include="MonoTouch.Dialog-1" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Resources\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Info.plist" />
|
||||
<None Include="Entitlements.plist" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AppDelegate.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
|
@ -0,0 +1,32 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||
# Visual Studio 2010
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ios7fonts", "ios7fonts.csproj", "{EC8BFD6D-FB32-4895-A962-B659ABE70798}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|iPhoneSimulator = Debug|iPhoneSimulator
|
||||
Release|iPhoneSimulator = Release|iPhoneSimulator
|
||||
Debug|iPhone = Debug|iPhone
|
||||
Release|iPhone = Release|iPhone
|
||||
Ad-Hoc|iPhone = Ad-Hoc|iPhone
|
||||
AppStore|iPhone = AppStore|iPhone
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{EC8BFD6D-FB32-4895-A962-B659ABE70798}.Ad-Hoc|iPhone.ActiveCfg = Ad-Hoc|iPhone
|
||||
{EC8BFD6D-FB32-4895-A962-B659ABE70798}.Ad-Hoc|iPhone.Build.0 = Ad-Hoc|iPhone
|
||||
{EC8BFD6D-FB32-4895-A962-B659ABE70798}.AppStore|iPhone.ActiveCfg = AppStore|iPhone
|
||||
{EC8BFD6D-FB32-4895-A962-B659ABE70798}.AppStore|iPhone.Build.0 = AppStore|iPhone
|
||||
{EC8BFD6D-FB32-4895-A962-B659ABE70798}.Debug|iPhone.ActiveCfg = Debug|iPhone
|
||||
{EC8BFD6D-FB32-4895-A962-B659ABE70798}.Debug|iPhone.Build.0 = Debug|iPhone
|
||||
{EC8BFD6D-FB32-4895-A962-B659ABE70798}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
|
||||
{EC8BFD6D-FB32-4895-A962-B659ABE70798}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
|
||||
{EC8BFD6D-FB32-4895-A962-B659ABE70798}.Release|iPhone.ActiveCfg = Release|iPhone
|
||||
{EC8BFD6D-FB32-4895-A962-B659ABE70798}.Release|iPhone.Build.0 = Release|iPhone
|
||||
{EC8BFD6D-FB32-4895-A962-B659ABE70798}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
|
||||
{EC8BFD6D-FB32-4895-A962-B659ABE70798}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
|
||||
EndGlobalSection
|
||||
GlobalSection(MonoDevelopProperties) = preSolution
|
||||
StartupItem = ios7fonts.csproj
|
||||
EndGlobalSection
|
||||
EndGlobal
|
Загрузка…
Ссылка в новой задаче