Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
154 lines (142 sloc) 6.5 KB
<Namespace Name="UIKit">
<Docs>
<summary>The UIKit namespace provides the primary user interface classes for Xamarin.iOS.</summary>
<remarks>
<para>
MonoTouch.UIKit is a binding to CocoaTouch's widget set. Use
the classes in this space to create native user interfaces with
iOS UIKit.
</para>
<para>
iOS Applications start as instances of the UIApplication
class, they can either be an instance of UIApplication or a
subclass of <see cref="T:UIKit.UIApplication" />.
This UIApplication object will invoke a number of methods in
response to starting up, shutting down, going to the
background and other interesting events by calling methods on
an instace of the <see cref="T:UIKit.UIApplicationDelegate" /> class. Most
applications will override the <format type="text/html"><a href="https://docs.microsoft.com/en-us/search/index?search=UIKit%20UIApplication%20Delegate%20Finished%20Launching&amp;scope=Xamarin" title="M:UIKit.UIApplicationDelegate.FinishedLaunching*">M:UIKit.UIApplicationDelegate.FinishedLaunching*</a></format> which is responsible for creating the main <see cref="T:UIKit.UIWindow" /> and configuring the
topmost <see cref="T:UIKit.UIViewController" /> to
display.
</para>
<para>
Most applications will create a single <see cref="T:UIKit.UIWindow" />, windows work in concert
with <see cref="T:UIKit.UIViewController" /> objects
which are in charge of orchestrating multiple views, handle
rotation and handle various events for the application. This is why on
startup, application developers must create both a window and sets its root view
controller, like this:
</para>
<example>
<code lang="C#"><![CDATA[
[Register ("AppDelegate")]
public partial class AppDelegate : UIApplicationDelegate
{
UIWindow window;
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
window = new UIWindow (UIScreen.MainScreen.Bounds);
window.RootViewController = new UIViewController ();
window.MakeKeyAndVisible ();
return true;
}
}
]]></code>
</example>
<para>
Response to user input is implemented in UIKit by subclasses of
<see cref="T:UIKit.UIResponder" />: UIApplication,
UIViewControllers and their subclasses and UIView and their
subclasses all inherit from this class.
</para>
<format type="text/html">
<h2>TextKit</h2>
</format>
<para>
Starting with iOS 7, the text rendering engine exposed on
UIKit was upgraded to expose a wide range of typographical
capabilities. This functionality was previously only
available when using the low-level <format type="text/html"><a href="https://docs.microsoft.com/en-us/search/index?search=Core%20Text&amp;scope=Xamarin" title="N:CoreText">N:CoreText</a></format> APIs. On iOS6, the "AttributedText" property was surfaced and application developers were limited to what was supported by attributed text, with iOS7, developers have access to the "TextStorage" property which provides full control of how things are rendered.
</para>
<para> TextKit supports: paginated text, text in columns, text
wrapping, rich text editing, interactive text coloring, text
folding, custom truncation, and dynamic type. </para>
<para>
The TextKit family of APIs provide a modern and sophisticated
text layout and rendering engine integrated right into UIKit.
This means that you can control the finer details of text
rendering on UIKit elements as well as integrating this with
animations. Because of this the controls in UIKit support all
text attributes and features like kernings and ligatures as
well as text effects like Letterpress.
</para>
<para>
Starting with iOS7 controls like <see cref="T:UIKit.UILabel" />, <see cref="T:UIKit.UITextField" /> and <see cref="T:UIKit.UITextView" /> are implemented using
TextKit directly, the same engine that powers WebKit (the <see cref="T:UIKit.UIWebView" /> control).
</para>
<format type="text/html">
<h3>Dynamic Type</h3>
</format>
<para>
In iOS 7, Apple introduced system-wide dynamic type, a set of fonts optimized for legibility at different magnifications. The end user selects the preferred size of dynamic text in device Settings. Applications receive the <c>ContentizeCategoryChanged</c> notification (see <see cref="M:UIKit.UIApplication.Notifications.ObserveContentSizeCategoryChanged*" />) and should reset the font size throughout their application's text views. The system-selected optimal fonts adjust such things as stroke weight and kerning as well as size, so application developers should use <see cref="T:UIKit.UIFont" />s <c>Preferred*</c> properties (e.g., <see cref="P:UIKit.UIFont.PreferredBody" />, <see cref="P:UIKit.UIFont.PreferredHeadline" />, etc. ), as shown in the following example:</para>
<example>
<code lang="C#"><![CDATA[
UIApplication.Notifications.ObserveContentSizeCategoryChanged((s,e) => {
SetDynamicTypeFonts();
});
//Call this when initializing, and also in response to ObserveContentSizeCategoryChanged notifications
private void SetDynamicTypeFonts()
{
headlineLabel.Font = UIFont.PreferredHeadline;
bodyText.Font = UIFont.PreferredBody;
//...etc...
}
]]></code>
</example>
<!-- TODO
<format type="text/html">
<h3>Font descriptors</h3>
</format>
<para>
Specifies a font, queries fonts, can be archived.
</para>
<format type="text/html">
<h3>Symbolic Traits</h3>
</format>
<format type="text/html">
<h3>Exclusion Paths</h3>
</format>
<format type="text/html">
<h3>UITextView Composition</h3>
</format>
<format type="text/html">
<h3>NSTextContainer</h3>
</format>
<para>
Coordinates for NSLayoutManager, Exclusion paths live in NSTextContainer coordinates.
</para>
<format type="text/html">
<h3>UITextView Composition</h3>
</format>
<format type="text/html">
<h3>Data Detectors</h3>
</format>
<format type="text/html">
<h3>Text Attachments</h3>
</format>
<para>
Used for things like inline images.
</para>
<format type="text/html">
<h3>Size Changes</h3>
</format>
<para>
Observe change. For Auto-layout, invalidate intrinsic content size. Use NeedsLayout if you laid objects manually to call the re-layout method. Invalidate font descriptors.
</para>
<format type="text/html">
<h3>UI Dynamics</h3>
</format>
-->
</remarks>
</Docs>
</Namespace>
You can’t perform that action at this time.