/// Configures and adds primary label view public static void AddInstructionView(this MaterialShowcase materialShowcase, CGPoint atCenter) { materialShowcase.instructionView = new MaterialShowcaseInstructionView(); materialShowcase.instructionView.primaryTextFont = materialShowcase.primaryTextFont; materialShowcase.instructionView.primaryTextSize = materialShowcase.primaryTextSize; materialShowcase.instructionView.primaryTextColor = materialShowcase.primaryTextColor; materialShowcase.instructionView.primaryText = materialShowcase.primaryText; materialShowcase.instructionView.secondaryTextFont = materialShowcase.secondaryTextFont; materialShowcase.instructionView.secondaryTextSize = materialShowcase.secondaryTextSize; materialShowcase.instructionView.secondaryTextColor = materialShowcase.secondaryTextColor; materialShowcase.instructionView.secondaryText = materialShowcase.secondaryText; // Calculate x position var xPosition = MaterialShowcase.LabelMargin; // Calculate y position float yPosition; if (materialShowcase.GetTargetPosition(materialShowcase.targetView, materialShowcase.containerView) == TargetPosition.Above) { yPosition = (float)atCenter.Y + MaterialShowcase.TextCenterOffset; } else { yPosition = (float)atCenter.Y - MaterialShowcase.TextCenterOffset - MaterialShowcase.LabelDefaultHeight * 2; } materialShowcase.instructionView.Frame = new CGRect( xPosition, yPosition, materialShowcase.containerView.Frame.Width - (xPosition + xPosition), 0); materialShowcase.AddSubview(materialShowcase.instructionView); }
public static CGPoint GetOuterCircleCenterPoint(this MaterialShowcase _materialShowcase, UIView _target) { if (_materialShowcase.IsInGutter(_target.Center)) { return(_target.Center); } var targetRadius = Math.Max(_target.Frame.Width, _target.Frame.Height) * .5f + MaterialShowcase.TargetPadding; var totalTextHeight = _materialShowcase.instructionView.Frame.Height; var onTop = _materialShowcase.GetTargetPosition(_materialShowcase.targetView, _materialShowcase.containerView) == MaterialShowcaseExtension.TargetPosition.Below; var left = Math.Min(_materialShowcase.instructionView.Frame.GetMinX(), _target.Frame.GetMinX() - targetRadius); var right = Math.Max(_materialShowcase.instructionView.Frame.GetMaxX(), _target.Frame.GetMaxX() + targetRadius); var titleHeight = _materialShowcase.instructionView.primaryLabel.Frame.Height; var centerY = onTop ? _target.Center.Y - MaterialShowcase.TargetHolderRadius - MaterialShowcase.TargetPadding - totalTextHeight + titleHeight : _target.Center.Y + MaterialShowcase.TargetHolderRadius + MaterialShowcase.TargetPadding + titleHeight; return(new CGPoint((left + right) * .5f, centerY)); }
/// Configures and adds primary label view public static void AddInstructionView(this MaterialShowcase materialShowcase, CGPoint atCenter) { materialShowcase.instructionView = new MaterialShowcaseInstructionView(); materialShowcase.instructionView.primaryTextFont = materialShowcase.primaryTextFont; materialShowcase.instructionView.primaryTextSize = materialShowcase.primaryTextSize; materialShowcase.instructionView.primaryTextColor = materialShowcase.primaryTextColor; materialShowcase.instructionView.primaryText = materialShowcase.primaryText; materialShowcase.instructionView.secondaryTextFont = materialShowcase.secondaryTextFont; materialShowcase.instructionView.secondaryTextSize = materialShowcase.secondaryTextSize; materialShowcase.instructionView.secondaryTextColor = materialShowcase.secondaryTextColor; materialShowcase.instructionView.secondaryText = materialShowcase.secondaryText; materialShowcase.instructionView.dismissText = materialShowcase.dismissText; materialShowcase.instructionView.dismissTextFont = materialShowcase.dismissTextFont; materialShowcase.instructionView.dismissTextColor = materialShowcase.dismissTextColor; materialShowcase.instructionView.dismissBackgroundColor = materialShowcase.dismissBackgroundColor; // Calculate x position var xPosition = UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad && UIDevice.CurrentDevice.Orientation.IsLandscape() ? MaterialShowcase.LabelMargin + SideMenuWidth : MaterialShowcase.LabelMargin; // Calculate y position float yPosition; if (materialShowcase.GetTargetPosition(materialShowcase.targetView, materialShowcase.containerView) == TargetPosition.Above) { yPosition = (float)atCenter.Y + MaterialShowcase.TextCenterOffset; } else { yPosition = (float)atCenter.Y - MaterialShowcase.TextCenterOffset - MaterialShowcase.LabelDefaultHeight * 2; } materialShowcase.instructionView.Frame = new CGRect( xPosition, yPosition, materialShowcase.containerView.Frame.Width - (xPosition + xPosition), 0); materialShowcase.AddSubview(materialShowcase.instructionView); }