summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.iOS
diff options
context:
space:
mode:
authorJason Smith <jason.smith@xamarin.com>2016-12-09 18:17:27 (GMT)
committerJason Smith <jason.smith@xamarin.com>2016-12-09 18:17:27 (GMT)
commit899e2bd591bf33cf99c1db95666f1313ff80565b (patch)
tree5f8712401e45895c8aaf79ce8674f76c7f387967 /Xamarin.Forms.Platform.iOS
parentc4b1c88f506ebf76a2a40f005b45ec9b24e46e1a (diff)
downloadxamarin-forms-899e2bd591bf33cf99c1db95666f1313ff80565b.zip
xamarin-forms-899e2bd591bf33cf99c1db95666f1313ff80565b.tar.gz
xamarin-forms-899e2bd591bf33cf99c1db95666f1313ff80565b.tar.bz2
Revert "Deprecate iOS 8 and earlier (#626)"
This reverts commit c4b1c88f506ebf76a2a40f005b45ec9b24e46e1a.
Diffstat (limited to 'Xamarin.Forms.Platform.iOS')
-rw-r--r--Xamarin.Forms.Platform.iOS/ContextActionCell.cs11
-rw-r--r--Xamarin.Forms.Platform.iOS/Forms.cs36
-rw-r--r--Xamarin.Forms.Platform.iOS/Platform.cs37
-rw-r--r--Xamarin.Forms.Platform.iOS/Renderers/ButtonRenderer.cs25
-rw-r--r--Xamarin.Forms.Platform.iOS/Renderers/CarouselPageRenderer.cs2
-rw-r--r--Xamarin.Forms.Platform.iOS/Renderers/EditorRenderer.cs7
-rw-r--r--Xamarin.Forms.Platform.iOS/Renderers/FontExtensions.cs17
-rw-r--r--Xamarin.Forms.Platform.iOS/Renderers/ListViewRenderer.cs20
-rw-r--r--Xamarin.Forms.Platform.iOS/Renderers/NavigationRenderer.cs54
-rw-r--r--Xamarin.Forms.Platform.iOS/Renderers/PageRenderer.cs2
-rw-r--r--Xamarin.Forms.Platform.iOS/Renderers/PhoneMasterDetailRenderer.cs2
-rw-r--r--Xamarin.Forms.Platform.iOS/Renderers/SearchBarRenderer.cs12
-rw-r--r--Xamarin.Forms.Platform.iOS/Renderers/TabbedRenderer.cs30
-rw-r--r--Xamarin.Forms.Platform.iOS/Renderers/TableViewModelRenderer.cs5
-rw-r--r--Xamarin.Forms.Platform.iOS/Renderers/TableViewRenderer.cs13
-rw-r--r--Xamarin.Forms.Platform.iOS/Renderers/TabletMasterDetailRenderer.cs12
-rw-r--r--Xamarin.Forms.Platform.iOS/ResourcesProvider.cs22
17 files changed, 257 insertions, 50 deletions
diff --git a/Xamarin.Forms.Platform.iOS/ContextActionCell.cs b/Xamarin.Forms.Platform.iOS/ContextActionCell.cs
index 469924c..39e0a35 100644
--- a/Xamarin.Forms.Platform.iOS/ContextActionCell.cs
+++ b/Xamarin.Forms.Platform.iOS/ContextActionCell.cs
@@ -169,7 +169,9 @@ namespace Xamarin.Forms.Platform.iOS
_scroller = new UIScrollView(new RectangleF(0, 0, width, height));
_scroller.ScrollsToTop = false;
_scroller.ShowsHorizontalScrollIndicator = false;
- _scroller.PreservesSuperviewLayoutMargins = true;
+
+ if (Forms.IsiOS8OrNewer)
+ _scroller.PreservesSuperviewLayoutMargins = true;
ContentView.AddSubview(_scroller);
}
@@ -297,8 +299,11 @@ namespace Xamarin.Forms.Platform.iOS
}
var frame = _moreButton.Frame;
- var container = _moreButton.Superview;
- frame = new RectangleF(container.Frame.X, 0, frame.Width, frame.Height);
+ if (!Forms.IsiOS8OrNewer)
+ {
+ var container = _moreButton.Superview;
+ frame = new RectangleF(container.Frame.X, 0, frame.Width, frame.Height);
+ }
var x = frame.X - _scroller.ContentOffset.X;
diff --git a/Xamarin.Forms.Platform.iOS/Forms.cs b/Xamarin.Forms.Platform.iOS/Forms.cs
index 0148451..820d3c0 100644
--- a/Xamarin.Forms.Platform.iOS/Forms.cs
+++ b/Xamarin.Forms.Platform.iOS/Forms.cs
@@ -24,6 +24,12 @@ namespace Xamarin.Forms
//Preserve GetCallingAssembly
static readonly bool nevertrue = false;
+ static bool? s_isiOS7OrNewer;
+
+ static bool? s_isiOS8OrNewer;
+
+ static bool? s_isiOS9OrNewer;
+
static Forms()
{
if (nevertrue)
@@ -32,6 +38,36 @@ namespace Xamarin.Forms
public static bool IsInitialized { get; private set; }
+ internal static bool IsiOS7OrNewer
+ {
+ get
+ {
+ if (!s_isiOS7OrNewer.HasValue)
+ s_isiOS7OrNewer = UIDevice.CurrentDevice.CheckSystemVersion(7, 0);
+ return s_isiOS7OrNewer.Value;
+ }
+ }
+
+ internal static bool IsiOS8OrNewer
+ {
+ get
+ {
+ if (!s_isiOS8OrNewer.HasValue)
+ s_isiOS8OrNewer = UIDevice.CurrentDevice.CheckSystemVersion(8, 0);
+ return s_isiOS8OrNewer.Value;
+ }
+ }
+
+ internal static bool IsiOS9OrNewer
+ {
+ get
+ {
+ if (!s_isiOS9OrNewer.HasValue)
+ s_isiOS9OrNewer = UIDevice.CurrentDevice.CheckSystemVersion(9, 0);
+ return s_isiOS9OrNewer.Value;
+ }
+ }
+
public static void Init()
{
if (IsInitialized)
diff --git a/Xamarin.Forms.Platform.iOS/Platform.cs b/Xamarin.Forms.Platform.iOS/Platform.cs
index 805aba7..c9c3188 100644
--- a/Xamarin.Forms.Platform.iOS/Platform.cs
+++ b/Xamarin.Forms.Platform.iOS/Platform.cs
@@ -46,7 +46,14 @@ namespace Xamarin.Forms.Platform.iOS
if (!PageIsChildOfPlatform(sender))
return;
- PresentAlert(arguments);
+ if (Forms.IsiOS8OrNewer)
+ {
+ PresentAlert(arguments);
+ }
+ else
+ {
+ PresentPre8Alert(arguments);
+ }
});
MessagingCenter.Subscribe(this, Page.ActionSheetSignalName, (Page sender, ActionSheetArguments arguments) =>
@@ -57,8 +64,16 @@ namespace Xamarin.Forms.Platform.iOS
var pageRoot = sender;
while (!Application.IsApplicationOrNull(pageRoot.RealParent))
pageRoot = (Page)pageRoot.RealParent;
+ var pageRenderer = GetRenderer(pageRoot);
- PresentActionSheet(arguments);
+ if (Forms.IsiOS8OrNewer)
+ {
+ PresentActionSheet(arguments);
+ }
+ else
+ {
+ PresentPre8ActionSheet(arguments, pageRenderer);
+ }
});
}
@@ -437,6 +452,12 @@ namespace Xamarin.Forms.Platform.iOS
alert.PopoverPresentationController.PermittedArrowDirections = 0; // No arrow
}
+ if(!Forms.IsiOS9OrNewer)
+ {
+ // For iOS 8, we need to explicitly set the size of the window
+ window.Frame = new RectangleF(0, 0, UIScreen.MainScreen.Bounds.Width, UIScreen.MainScreen.Bounds.Height);
+ }
+
window.RootViewController.PresentViewController(alert, true, null);
}
@@ -470,6 +491,18 @@ namespace Xamarin.Forms.Platform.iOS
await Task.Delay(5);
}
+ void PresentPre8Alert(AlertArguments arguments)
+ {
+ UIAlertView alertView;
+ if (arguments.Accept != null)
+ alertView = new UIAlertView(arguments.Title, arguments.Message, null, arguments.Cancel, arguments.Accept);
+ else
+ alertView = new UIAlertView(arguments.Title, arguments.Message, null, arguments.Cancel);
+
+ alertView.Dismissed += (o, args) => arguments.SetResult(args.ButtonIndex != 0);
+ alertView.Show();
+ }
+
void PresentPre8ActionSheet(ActionSheetArguments arguments, IVisualElementRenderer pageRenderer)
{
var actionSheet = new UIActionSheet(arguments.Title, null, arguments.Cancel, arguments.Destruction,
diff --git a/Xamarin.Forms.Platform.iOS/Renderers/ButtonRenderer.cs b/Xamarin.Forms.Platform.iOS/Renderers/ButtonRenderer.cs
index 9942623..8d043ba 100644
--- a/Xamarin.Forms.Platform.iOS/Renderers/ButtonRenderer.cs
+++ b/Xamarin.Forms.Platform.iOS/Renderers/ButtonRenderer.cs
@@ -82,6 +82,8 @@ namespace Xamarin.Forms.Platform.iOS
UpdateFont();
else if (e.PropertyName == Button.BorderWidthProperty.PropertyName || e.PropertyName == Button.BorderRadiusProperty.PropertyName || e.PropertyName == Button.BorderColorProperty.PropertyName)
UpdateBorder();
+ else if (e.PropertyName == VisualElement.BackgroundColorProperty.PropertyName)
+ UpdateBackgroundVisibility();
else if (e.PropertyName == Button.ImageProperty.PropertyName)
UpdateImage();
}
@@ -91,6 +93,18 @@ namespace Xamarin.Forms.Platform.iOS
((IButtonController)Element)?.SendClicked();
}
+ void UpdateBackgroundVisibility()
+ {
+ if (Forms.IsiOS7OrNewer)
+ return;
+
+ var model = Element;
+ var shouldDrawImage = model.BackgroundColor == Color.Default;
+
+ foreach (var control in Control.Subviews.Where(sv => !(sv is UILabel)))
+ control.Alpha = shouldDrawImage ? 1.0f : 0.0f;
+ }
+
void UpdateBorder()
{
var uiButton = Control;
@@ -101,6 +115,8 @@ namespace Xamarin.Forms.Platform.iOS
uiButton.Layer.BorderWidth = Math.Max(0f, (float)button.BorderWidth);
uiButton.Layer.CornerRadius = button.BorderRadius;
+
+ UpdateBackgroundVisibility();
}
void UpdateFont()
@@ -126,7 +142,10 @@ namespace Xamarin.Forms.Platform.iOS
UIButton button = Control;
if (button != null && uiimage != null)
{
- button.SetImage(uiimage.ImageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal), UIControlState.Normal);
+ if (Forms.IsiOS7OrNewer)
+ button.SetImage(uiimage.ImageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal), UIControlState.Normal);
+ else
+ button.SetImage(uiimage, UIControlState.Normal);
button.ImageView.ContentMode = UIViewContentMode.ScaleAspectFit;
@@ -165,7 +184,9 @@ namespace Xamarin.Forms.Platform.iOS
Control.SetTitleColor(Element.TextColor.ToUIColor(), UIControlState.Normal);
Control.SetTitleColor(Element.TextColor.ToUIColor(), UIControlState.Highlighted);
Control.SetTitleColor(_buttonTextColorDefaultDisabled, UIControlState.Disabled);
- Control.TintColor = Element.TextColor.ToUIColor();
+
+ if (Forms.IsiOS7OrNewer)
+ Control.TintColor = Element.TextColor.ToUIColor();
}
}
diff --git a/Xamarin.Forms.Platform.iOS/Renderers/CarouselPageRenderer.cs b/Xamarin.Forms.Platform.iOS/Renderers/CarouselPageRenderer.cs
index f1364de..58587e8 100644
--- a/Xamarin.Forms.Platform.iOS/Renderers/CarouselPageRenderer.cs
+++ b/Xamarin.Forms.Platform.iOS/Renderers/CarouselPageRenderer.cs
@@ -22,6 +22,8 @@ namespace Xamarin.Forms.Platform.iOS
public CarouselPageRenderer()
{
+ if (!Forms.IsiOS7OrNewer)
+ WantsFullScreenLayout = true;
}
IElementController ElementController => Element as IElementController;
diff --git a/Xamarin.Forms.Platform.iOS/Renderers/EditorRenderer.cs b/Xamarin.Forms.Platform.iOS/Renderers/EditorRenderer.cs
index 96e8933..8819ba3 100644
--- a/Xamarin.Forms.Platform.iOS/Renderers/EditorRenderer.cs
+++ b/Xamarin.Forms.Platform.iOS/Renderers/EditorRenderer.cs
@@ -13,7 +13,12 @@ namespace Xamarin.Forms.Platform.iOS
public override SizeRequest GetDesiredSize(double widthConstraint, double heightConstraint)
{
- return base.GetDesiredSize(Math.Min(widthConstraint, 2000), Math.Min(heightConstraint, 2000));
+ if (!Forms.IsiOS7OrNewer)
+ {
+ // Avoid crash iOS 6. iOS 6, I hate you. Why you no like Infinite size?
+ return base.GetDesiredSize(Math.Min(widthConstraint, 2000), Math.Min(heightConstraint, 2000));
+ }
+ return base.GetDesiredSize(widthConstraint, heightConstraint);
}
protected override void Dispose(bool disposing)
diff --git a/Xamarin.Forms.Platform.iOS/Renderers/FontExtensions.cs b/Xamarin.Forms.Platform.iOS/Renderers/FontExtensions.cs
index 6a6eb63..ae16c66 100644
--- a/Xamarin.Forms.Platform.iOS/Renderers/FontExtensions.cs
+++ b/Xamarin.Forms.Platform.iOS/Renderers/FontExtensions.cs
@@ -41,7 +41,7 @@ namespace Xamarin.Forms.Platform.iOS
{
try
{
- if (UIFont.FamilyNames.Contains(self.FontFamily))
+ if (UIFont.FamilyNames.Contains(self.FontFamily) && Forms.IsiOS7OrNewer)
{
var descriptor = new UIFontDescriptor().CreateWithFamily(self.FontFamily);
@@ -67,6 +67,12 @@ namespace Xamarin.Forms.Platform.iOS
}
if (bold && italic)
{
+ if (!Forms.IsiOS7OrNewer)
+ {
+ // not sure how to make a font both bold and italic in iOS 6, default to bold
+ return UIFont.BoldSystemFontOfSize(size);
+ }
+
var defaultFont = UIFont.SystemFontOfSize(size);
var descriptor = defaultFont.FontDescriptor.CreateWithTraits(UIFontDescriptorSymbolicTraits.Bold | UIFontDescriptorSymbolicTraits.Italic);
return UIFont.FromDescriptor(descriptor, 0);
@@ -104,7 +110,7 @@ namespace Xamarin.Forms.Platform.iOS
try
{
UIFont result;
- if (UIFont.FamilyNames.Contains(family))
+ if (UIFont.FamilyNames.Contains(family) && Forms.IsiOS7OrNewer)
{
var descriptor = new UIFontDescriptor().CreateWithFamily(family);
@@ -136,6 +142,13 @@ namespace Xamarin.Forms.Platform.iOS
if (bold && italic)
{
var defaultFont = UIFont.SystemFontOfSize(size);
+
+ if (!Forms.IsiOS7OrNewer)
+ {
+ // not sure how to make a font both bold and italic in iOS 6, default to bold
+ return UIFont.BoldSystemFontOfSize(size);
+ }
+
var descriptor = defaultFont.FontDescriptor.CreateWithTraits(UIFontDescriptorSymbolicTraits.Bold | UIFontDescriptorSymbolicTraits.Italic);
return UIFont.FromDescriptor(descriptor, 0);
}
diff --git a/Xamarin.Forms.Platform.iOS/Renderers/ListViewRenderer.cs b/Xamarin.Forms.Platform.iOS/Renderers/ListViewRenderer.cs
index db57570..3913632 100644
--- a/Xamarin.Forms.Platform.iOS/Renderers/ListViewRenderer.cs
+++ b/Xamarin.Forms.Platform.iOS/Renderers/ListViewRenderer.cs
@@ -184,7 +184,8 @@ namespace Xamarin.Forms.Platform.iOS
{
_tableViewController = new FormsUITableViewController(e.NewElement);
SetNativeControl(_tableViewController.TableView);
- Control.CellLayoutMarginsFollowReadableWidth = false;
+ if (Forms.IsiOS9OrNewer)
+ Control.CellLayoutMarginsFollowReadableWidth = false;
_insetTracker = new KeyboardInsetTracker(_tableViewController.TableView, () => Control.Window, insets => Control.ContentInset = Control.ScrollIndicatorInsets = insets, point =>
{
@@ -369,7 +370,8 @@ namespace Xamarin.Forms.Platform.iOS
}
else
{
- Control.EstimatedRowHeight = 0;
+ if (Forms.IsiOS7OrNewer)
+ Control.EstimatedRowHeight = 0;
_estimatedRowHeight = true;
}
}
@@ -558,9 +560,10 @@ namespace Xamarin.Forms.Platform.iOS
void UpdateRowHeight()
{
var rowHeight = Element.RowHeight;
- if (Element.HasUnevenRows && rowHeight == -1)
+ if (Element.HasUnevenRows && rowHeight == -1 && Forms.IsiOS7OrNewer)
{
- Control.RowHeight = UITableView.AutomaticDimension;
+ if (Forms.IsiOS8OrNewer)
+ Control.RowHeight = UITableView.AutomaticDimension;
}
else
Control.RowHeight = rowHeight <= 0 ? DefaultRowHeight : rowHeight;
@@ -610,7 +613,9 @@ namespace Xamarin.Forms.Platform.iOS
if (List.RowHeight == -1 && cell.Height == -1 && cell is ViewCell)
{
// only doing ViewCell because its the only one that matters (the others dont adjust ANYWAY)
- return UITableView.AutomaticDimension;
+ if (Forms.IsiOS8OrNewer)
+ return UITableView.AutomaticDimension;
+ return CalculateHeightForCell(tableView, cell);
}
var renderHeight = cell.RenderHeight;
@@ -676,7 +681,7 @@ namespace Xamarin.Forms.Platform.iOS
{
_uiTableViewController = uiTableViewController;
_uiTableView = uiTableViewController.TableView;
- _defaultSectionHeight = DefaultRowHeight;
+ _defaultSectionHeight = Forms.IsiOS8OrNewer ? DefaultRowHeight : _uiTableView.SectionHeaderHeight;
List = list;
List.ItemSelected += OnItemSelected;
UpdateShortNameListener();
@@ -1002,7 +1007,8 @@ namespace Xamarin.Forms.Platform.iOS
public FormsUITableViewController(ListView element)
{
- TableView.CellLayoutMarginsFollowReadableWidth = false;
+ if (Forms.IsiOS9OrNewer)
+ TableView.CellLayoutMarginsFollowReadableWidth = false;
_refresh = new UIRefreshControl();
_refresh.ValueChanged += OnRefreshingChanged;
_list = element;
diff --git a/Xamarin.Forms.Platform.iOS/Renderers/NavigationRenderer.cs b/Xamarin.Forms.Platform.iOS/Renderers/NavigationRenderer.cs
index 60ae185..adf3219 100644
--- a/Xamarin.Forms.Platform.iOS/Renderers/NavigationRenderer.cs
+++ b/Xamarin.Forms.Platform.iOS/Renderers/NavigationRenderer.cs
@@ -182,7 +182,13 @@ namespace Xamarin.Forms.Platform.iOS
{
base.ViewDidLoad();
- UpdateTranslucent();
+ if (Forms.IsiOS7OrNewer)
+ {
+
+ UpdateTranslucent();
+ }
+ else
+ WantsFullScreenLayout = false;
_secondaryToolbar = new SecondaryToolbar { Frame = new RectangleF(0, 0, 320, 44) };
View.Add(_secondaryToolbar);
@@ -448,6 +454,11 @@ namespace Xamarin.Forms.Platform.iOS
void UpdateTranslucent()
{
+ if (!Forms.IsiOS7OrNewer)
+ {
+ return;
+ }
+
NavigationBar.Translucent = ((NavigationPage)Element).OnThisPlatform().IsNavigationBarTranslucent();
}
@@ -560,9 +571,18 @@ namespace Xamarin.Forms.Platform.iOS
{
var barBackgroundColor = ((NavigationPage)Element).BarBackgroundColor;
// Set navigation bar background color
- NavigationBar.BarTintColor = barBackgroundColor == Color.Default
- ? UINavigationBar.Appearance.BarTintColor
- : barBackgroundColor.ToUIColor();
+ if (Forms.IsiOS7OrNewer)
+ {
+ NavigationBar.BarTintColor = barBackgroundColor == Color.Default
+ ? UINavigationBar.Appearance.BarTintColor
+ : barBackgroundColor.ToUIColor();
+ }
+ else
+ {
+ NavigationBar.TintColor = barBackgroundColor == Color.Default
+ ? UINavigationBar.Appearance.TintColor
+ : barBackgroundColor.ToUIColor();
+ }
}
void UpdateBarTextColor()
@@ -596,9 +616,12 @@ namespace Xamarin.Forms.Platform.iOS
var statusBarColorMode = (Element as NavigationPage).OnThisPlatform().GetStatusBarTextColorMode();
// set Tint color (i. e. Back Button arrow and Text)
- NavigationBar.TintColor = barTextColor == Color.Default || statusBarColorMode == StatusBarTextColorMode.DoNotAdjust
+ if (Forms.IsiOS7OrNewer)
+ {
+ NavigationBar.TintColor = barTextColor == Color.Default || statusBarColorMode == StatusBarTextColorMode.DoNotAdjust
? UINavigationBar.Appearance.TintColor
: barTextColor.ToUIColor();
+ }
if (statusBarColorMode == StatusBarTextColorMode.DoNotAdjust || barTextColor.Luminosity <= 0.5)
{
@@ -656,13 +679,18 @@ namespace Xamarin.Forms.Platform.iOS
#pragma warning disable 0618 //retaining legacy call to obsolete code
var tintColor = ((NavigationPage)Element).Tint;
#pragma warning restore 0618
- NavigationBar.BarTintColor = tintColor == Color.Default
- ? UINavigationBar.Appearance.BarTintColor
- : tintColor.ToUIColor();
- if (tintColor == Color.Default)
- NavigationBar.TintColor = UINavigationBar.Appearance.TintColor;
+ if (Forms.IsiOS7OrNewer)
+ {
+ NavigationBar.BarTintColor = tintColor == Color.Default
+ ? UINavigationBar.Appearance.BarTintColor
+ : tintColor.ToUIColor();
+ if (tintColor == Color.Default)
+ NavigationBar.TintColor = UINavigationBar.Appearance.TintColor;
+ else
+ NavigationBar.TintColor = tintColor.Luminosity > 0.5 ? UIColor.Black : UIColor.White;
+ }
else
- NavigationBar.TintColor = tintColor.Luminosity > 0.5 ? UIColor.Black : UIColor.White;
+ NavigationBar.TintColor = tintColor == Color.Default ? null : tintColor.ToUIColor();
}
void UpdateToolBarVisible()
@@ -748,7 +776,9 @@ namespace Xamarin.Forms.Platform.iOS
public ParentingViewController(NavigationRenderer navigation)
{
- AutomaticallyAdjustsScrollViewInsets = false;
+ if (Forms.IsiOS7OrNewer)
+ AutomaticallyAdjustsScrollViewInsets = false;
+
_navigation = new WeakReference<NavigationRenderer>(navigation);
}
diff --git a/Xamarin.Forms.Platform.iOS/Renderers/PageRenderer.cs b/Xamarin.Forms.Platform.iOS/Renderers/PageRenderer.cs
index e2455d7..1f7408b 100644
--- a/Xamarin.Forms.Platform.iOS/Renderers/PageRenderer.cs
+++ b/Xamarin.Forms.Platform.iOS/Renderers/PageRenderer.cs
@@ -19,6 +19,8 @@ namespace Xamarin.Forms.Platform.iOS
public PageRenderer()
{
+ if (!Forms.IsiOS7OrNewer)
+ WantsFullScreenLayout = true;
}
void IEffectControlProvider.RegisterEffect(Effect effect)
diff --git a/Xamarin.Forms.Platform.iOS/Renderers/PhoneMasterDetailRenderer.cs b/Xamarin.Forms.Platform.iOS/Renderers/PhoneMasterDetailRenderer.cs
index 501312c..627bec7 100644
--- a/Xamarin.Forms.Platform.iOS/Renderers/PhoneMasterDetailRenderer.cs
+++ b/Xamarin.Forms.Platform.iOS/Renderers/PhoneMasterDetailRenderer.cs
@@ -28,6 +28,8 @@ namespace Xamarin.Forms.Platform.iOS
public PhoneMasterDetailRenderer()
{
+ if (!Forms.IsiOS7OrNewer)
+ WantsFullScreenLayout = true;
}
IMasterDetailPageController MasterDetailPageController => Element as IMasterDetailPageController;
diff --git a/Xamarin.Forms.Platform.iOS/Renderers/SearchBarRenderer.cs b/Xamarin.Forms.Platform.iOS/Renderers/SearchBarRenderer.cs
index a9af856..8c54702 100644
--- a/Xamarin.Forms.Platform.iOS/Renderers/SearchBarRenderer.cs
+++ b/Xamarin.Forms.Platform.iOS/Renderers/SearchBarRenderer.cs
@@ -106,9 +106,17 @@ namespace Xamarin.Forms.Platform.iOS
return;
if (_defaultTintColor == null)
- _defaultTintColor = Control.BarTintColor;
+ {
+ if (Forms.IsiOS7OrNewer)
+ _defaultTintColor = Control.BarTintColor;
+ else
+ _defaultTintColor = Control.TintColor;
+ }
- Control.BarTintColor = color.ToUIColor(_defaultTintColor);
+ if (Forms.IsiOS7OrNewer)
+ Control.BarTintColor = color.ToUIColor(_defaultTintColor);
+ else
+ Control.TintColor = color.ToUIColor(_defaultTintColor);
if (color.A < 1)
Control.SetBackgroundImage(new UIImage(), UIBarPosition.Any, UIBarMetrics.Default);
diff --git a/Xamarin.Forms.Platform.iOS/Renderers/TabbedRenderer.cs b/Xamarin.Forms.Platform.iOS/Renderers/TabbedRenderer.cs
index f7ca834..c6c0737 100644
--- a/Xamarin.Forms.Platform.iOS/Renderers/TabbedRenderer.cs
+++ b/Xamarin.Forms.Platform.iOS/Renderers/TabbedRenderer.cs
@@ -134,6 +134,14 @@ namespace Xamarin.Forms.Platform.iOS
_loaded = true;
}
+ public override void ViewDidLoad()
+ {
+ base.ViewDidLoad();
+
+ if (!Forms.IsiOS7OrNewer)
+ WantsFullScreenLayout = false;
+ }
+
protected override void Dispose(bool disposing)
{
if (disposing)
@@ -306,14 +314,25 @@ namespace Xamarin.Forms.Platform.iOS
if (!_defaultBarColorSet)
{
- _defaultBarColor = TabBar.BarTintColor;
+ if (Forms.IsiOS7OrNewer)
+ _defaultBarColor = TabBar.BarTintColor;
+ else
+ _defaultBarColor = TabBar.TintColor;
+
_defaultBarColorSet = true;
}
if (!isDefaultColor)
_barBackgroundColorWasSet = true;
- TabBar.BarTintColor = isDefaultColor ? _defaultBarColor : barBackgroundColor.ToUIColor();
+ if (Forms.IsiOS7OrNewer)
+ {
+ TabBar.BarTintColor = isDefaultColor ? _defaultBarColor : barBackgroundColor.ToUIColor();
+ }
+ else
+ {
+ TabBar.TintColor = isDefaultColor ? _defaultBarColor : barBackgroundColor.ToUIColor();
+ }
}
void UpdateBarTextColor()
@@ -348,7 +367,12 @@ namespace Xamarin.Forms.Platform.iOS
item.SetTitleTextAttributes(attributes, UIControlState.Normal);
}
- TabBar.TintColor = isDefaultColor ? _defaultBarTextColor : barTextColor.ToUIColor();
+ // set TintColor for selected icon
+ // setting the unselected icon tint is not supported by iOS
+ if (Forms.IsiOS7OrNewer)
+ {
+ TabBar.TintColor = isDefaultColor ? _defaultBarTextColor : barTextColor.ToUIColor();
+ }
}
void UpdateChildrenOrderIndex(UIViewController[] viewControllers)
diff --git a/Xamarin.Forms.Platform.iOS/Renderers/TableViewModelRenderer.cs b/Xamarin.Forms.Platform.iOS/Renderers/TableViewModelRenderer.cs
index 2a75458..4a9f694 100644
--- a/Xamarin.Forms.Platform.iOS/Renderers/TableViewModelRenderer.cs
+++ b/Xamarin.Forms.Platform.iOS/Renderers/TableViewModelRenderer.cs
@@ -137,11 +137,10 @@ namespace Xamarin.Forms.Platform.iOS
var cell = View.Model.GetCell(indexPath.Section, indexPath.Row);
var h = cell.Height;
- if (View.RowHeight == -1 && h == -1 && cell is ViewCell)
+ if (View.RowHeight == -1 && h == -1 && cell is ViewCell && Forms.IsiOS8OrNewer) {
return UITableView.AutomaticDimension;
- else if (h == -1)
+ } else if (h == -1)
return tableView.RowHeight;
-
return (nfloat)h;
}
}
diff --git a/Xamarin.Forms.Platform.iOS/Renderers/TableViewRenderer.cs b/Xamarin.Forms.Platform.iOS/Renderers/TableViewRenderer.cs
index 0009ace..725ef51 100644
--- a/Xamarin.Forms.Platform.iOS/Renderers/TableViewRenderer.cs
+++ b/Xamarin.Forms.Platform.iOS/Renderers/TableViewRenderer.cs
@@ -73,7 +73,8 @@ namespace Xamarin.Forms.Platform.iOS
_originalBackgroundView = tv.BackgroundView;
SetNativeControl(tv);
- tv.CellLayoutMarginsFollowReadableWidth = false;
+ if (Forms.IsiOS9OrNewer)
+ tv.CellLayoutMarginsFollowReadableWidth = false;
_insetTracker = new KeyboardInsetTracker(tv, () => Control.Window, insets => Control.ContentInset = Control.ScrollIndicatorInsets = insets, point =>
{
@@ -133,9 +134,10 @@ namespace Xamarin.Forms.Platform.iOS
void UpdateRowHeight()
{
var rowHeight = Element.RowHeight;
- if (Element.HasUnevenRows && rowHeight == -1)
- Control.RowHeight = UITableView.AutomaticDimension;
- else
+ if (Element.HasUnevenRows && rowHeight == -1 && Forms.IsiOS7OrNewer) {
+ if (Forms.IsiOS8OrNewer)
+ Control.RowHeight = UITableView.AutomaticDimension;
+ } else
Control.RowHeight = rowHeight <= 0 ? DefaultRowHeight : rowHeight;
}
@@ -145,7 +147,8 @@ namespace Xamarin.Forms.Platform.iOS
if (Element.HasUnevenRows && rowHeight == -1) {
Control.EstimatedRowHeight = DefaultRowHeight;
} else {
- Control.EstimatedRowHeight = 0;
+ if (Forms.IsiOS7OrNewer)
+ Control.EstimatedRowHeight = 0;
}
}
}
diff --git a/Xamarin.Forms.Platform.iOS/Renderers/TabletMasterDetailRenderer.cs b/Xamarin.Forms.Platform.iOS/Renderers/TabletMasterDetailRenderer.cs
index 9f0dff0..e72b243 100644
--- a/Xamarin.Forms.Platform.iOS/Renderers/TabletMasterDetailRenderer.cs
+++ b/Xamarin.Forms.Platform.iOS/Renderers/TabletMasterDetailRenderer.cs
@@ -223,8 +223,11 @@ namespace Xamarin.Forms.Platform.iOS
if (!MasterDetailPageController.ShouldShowSplitMode && _masterVisible)
{
MasterDetailPageController.CanChangeIsPresented = true;
- PreferredDisplayMode = UISplitViewControllerDisplayMode.PrimaryHidden;
- PreferredDisplayMode = UISplitViewControllerDisplayMode.Automatic;
+ if (Forms.IsiOS8OrNewer)
+ {
+ PreferredDisplayMode = UISplitViewControllerDisplayMode.PrimaryHidden;
+ PreferredDisplayMode = UISplitViewControllerDisplayMode.Automatic;
+ }
}
MasterDetailPageController.UpdateMasterBehavior();
@@ -304,7 +307,10 @@ namespace Xamarin.Forms.Platform.iOS
void PerformButtonSelector()
{
- DisplayModeButtonItem.Target.PerformSelector(DisplayModeButtonItem.Action, DisplayModeButtonItem, 0);
+ if (Forms.IsiOS8OrNewer)
+ DisplayModeButtonItem.Target.PerformSelector(DisplayModeButtonItem.Action, DisplayModeButtonItem, 0);
+ else
+ PresentButton.Target.PerformSelector(PresentButton.Action, PresentButton, 0);
}
void ToggleMaster()
diff --git a/Xamarin.Forms.Platform.iOS/ResourcesProvider.cs b/Xamarin.Forms.Platform.iOS/ResourcesProvider.cs
index 59f9504..cb5e3cf 100644
--- a/Xamarin.Forms.Platform.iOS/ResourcesProvider.cs
+++ b/Xamarin.Forms.Platform.iOS/ResourcesProvider.cs
@@ -8,7 +8,8 @@ namespace Xamarin.Forms.Platform.iOS
public ResourcesProvider()
{
- UIApplication.Notifications.ObserveContentSizeCategoryChanged((sender, args) => UpdateStyles());
+ if (Forms.IsiOS7OrNewer)
+ UIApplication.Notifications.ObserveContentSizeCategoryChanged((sender, args) => UpdateStyles());
}
public IResourceDictionary GetSystemResources()
@@ -44,10 +45,21 @@ namespace Xamarin.Forms.Platform.iOS
void UpdateStyles()
{
- _dictionary[Device.Styles.TitleStyleKey] = GenerateStyle(UIFont.PreferredHeadline);
- _dictionary[Device.Styles.SubtitleStyleKey] = GenerateStyle(UIFont.PreferredSubheadline);
- _dictionary[Device.Styles.BodyStyleKey] = GenerateStyle(UIFont.PreferredBody);
- _dictionary[Device.Styles.CaptionStyleKey] = GenerateStyle(UIFont.PreferredCaption1);
+ if (Forms.IsiOS7OrNewer)
+ {
+ _dictionary[Device.Styles.TitleStyleKey] = GenerateStyle(UIFont.PreferredHeadline);
+ _dictionary[Device.Styles.SubtitleStyleKey] = GenerateStyle(UIFont.PreferredSubheadline);
+ _dictionary[Device.Styles.BodyStyleKey] = GenerateStyle(UIFont.PreferredBody);
+ _dictionary[Device.Styles.CaptionStyleKey] = GenerateStyle(UIFont.PreferredCaption1);
+ }
+ else
+ {
+ _dictionary[Device.Styles.TitleStyleKey] = GenerateStyle(UIFont.BoldSystemFontOfSize(17));
+ _dictionary[Device.Styles.SubtitleStyleKey] = GenerateStyle(UIFont.SystemFontOfSize(15));
+ _dictionary[Device.Styles.BodyStyleKey] = GenerateStyle(UIFont.SystemFontOfSize(17));
+ _dictionary[Device.Styles.CaptionStyleKey] = GenerateStyle(UIFont.SystemFontOfSize(12));
+ }
+
_dictionary[Device.Styles.ListItemTextStyleKey] = GenerateListItemTextStyle();
_dictionary[Device.Styles.ListItemDetailTextStyleKey] = GenerateListItemDetailTextStyle();
}