<Button Text="Some Text" />
<Button Image="bank.png" />
<Button Text="Some Text" Image="bank.png" />
+ <Button Text="Some Text" Image="bank.png" ContentLayout="Top, 8" />
+ <Button Text="Some Text" Image="bank.png" ContentLayout="Right, 8" />
+ <Button Text="Some Text" Image="bank.png" ContentLayout="Bottom, 8" />
+ <Button Text="Some Text" Image="bank.png" ContentLayout="Left, 8" />
</StackLayout>
<Label Text="Autosized:" Margin="0,0,0,-5" />
using System.ComponentModel;
using System.Threading.Tasks;
using CoreGraphics;
+using Foundation;
using UIKit;
namespace Xamarin.Forms.Platform.iOS
{
// TODO: Do not use the title label as it is not yet updated and
// if we move the image, then we technically have more
- // space and will require a new laoyt pass.
-
- var titleRect = control.TitleLabel.Bounds.Size;
+ // space and will require a new layout pass.
+
+ var title =
+ control.CurrentAttributedTitle ??
+ new NSAttributedString(control.CurrentTitle, new UIStringAttributes { Font = control.TitleLabel.Font });
+ var titleRect = title.GetBoundingRect(
+ control.Bounds.Size,
+ NSStringDrawingOptions.UsesLineFragmentOrigin | NSStringDrawingOptions.UsesFontLeading,
+ null);
var titleWidth = titleRect.Width;
var titleHeight = titleRect.Height;