本文整理汇总了C#中UIButton.Add方法的典型用法代码示例。如果您正苦于以下问题:C# UIButton.Add方法的具体用法?C# UIButton.Add怎么用?C# UIButton.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UIButton
的用法示例。
在下文中一共展示了UIButton.Add方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ImageAndTitleHeaderView
public ImageAndTitleHeaderView()
: base(new CGRect(0, 0, 320f, 100f))
{
ImageButton = new UIButton(UIButtonType.Custom);
ImageButton.Frame = new CGRect(0, 0, 80, 80);
ImageButton.TouchUpInside += (sender, e) => {
if (ImageButtonAction != null)
ImageButtonAction();
};
Add(ImageButton);
_imageView = new UIImageView();
_imageView.Frame = new CGRect(0, 0, 80, 80);
_imageView.BackgroundColor = UIColor.White;
_imageView.Layer.BorderWidth = 2f;
_imageView.Layer.BorderColor = UIColor.White.CGColor;
ImageButton.Add(_imageView);
_label = new UILabel();
_label.TextAlignment = UITextAlignment.Center;
_label.Lines = 0;
_label.Font = UIFont.PreferredHeadline;
Add(_label);
_label2 = new UILabel();
_label2.Hidden = true;
_label2.TextAlignment = UITextAlignment.Center;
_label2.Font = UIFont.PreferredSubheadline;
_label2.Lines = 0;
Add(_label2);
_seperatorView = new UIView();
_seperatorView.BackgroundColor = UIColor.FromWhiteAlpha(214.0f / 255.0f, 1.0f);
Add(_seperatorView);
_subView = new UIView();
_subView.Frame = new CGRect(56, 56, 22, 22);
_subView.Layer.CornerRadius = 10f;
_subView.Layer.MasksToBounds = true;
_subView.BackgroundColor = UIColor.White;
_subView.Hidden = true;
ImageButton.Add(_subView);
_subImageView = new UIImageView(new CGRect(0, 0, _subView.Frame.Width - 4f, _subView.Frame.Height - 4f));
_subImageView.Center = new CGPoint(11f, 11f);
_subView.Add(_subImageView);
EnableSeperator = false;
RoundedImage = true;
}
示例2: BlurredAlertView
private BlurredAlertView(string text)
{
_label = new UILabel();
_label.Lines = 0;
_label.Text = text;
_label.Font = UIFont.PreferredHeadline;
_label.TextAlignment = UITextAlignment.Center;
_label.TextColor = UIColor.White;
_button = new UIButton(UIButtonType.Custom);
var buttonLabel = new UILabel();
buttonLabel.Text = "Ok";
buttonLabel.Font = UIFont.PreferredBody.MakeBold();
buttonLabel.TextColor = UIColor.White;
buttonLabel.SizeToFit();
buttonLabel.AutoresizingMask = UIViewAutoresizing.FlexibleMargins;
_button.Add(buttonLabel);
_button.Layer.BorderColor = UIColor.White.CGColor;
_button.Layer.BorderWidth = 1f;
_button.Layer.CornerRadius = 6f;
_button.Layer.MasksToBounds = true;
}
示例3: ViewDidLoad
public override void ViewDidLoad() {
base.ViewDidLoad();
View.AutoresizingMask = UIViewAutoresizing.FlexibleDimensions;
View.BackgroundColor = UIColor.White;
var ratingConfig = new RatingConfig(emptyImage: UIImage.FromBundle("Stars/empty"),
filledImage: UIImage.FromBundle("Stars/filled"),
chosenImage: UIImage.FromBundle("Stars/chosen"));
// [Optional] Put a little space between the rating items.
ratingConfig.ItemPadding = 5f;
backgroundButton = UIButton.FromType(UIButtonType.RoundedRect);
backgroundButton.SetBackgroundImage(UIImage.FromBundle("Background/background").StretchableImage(0, 0), UIControlState.Normal);
backgroundButton.Frame = new CGRect(new CGPoint(24f, 24f), new CGSize(View.Bounds.Width - (2f * 24f), 125f));
var ratingFrame = backgroundButton.Bounds;
ratingView = new PDRatingView(ratingFrame, ratingConfig);
// [Optional] Set the current rating to display.
decimal rating = 3.58m;
//decimal halfRoundedRating = Math.Round(rating * 2m, MidpointRounding.AwayFromZero) / 2m;
//decimal wholeRoundedRating = Math.Round(rating, MidpointRounding.AwayFromZero);
ratingView.AverageRating = rating;
// [Optional] Make it read-only to keep the user from setting a rating.
//StarRating.UserInteractionEnabled = false;
// [Optional] Attach to the rating event to do something with the chosen value.
ratingView.RatingChosen += (sender, e) => {
(new UIAlertView("Rated!", e.Rating.ToString() + " stars", null, "Ok")).Show();
};
backgroundButton.Add(ratingView);
View.Add(backgroundButton);
}
示例4: GetBackButton
private static UIView GetBackButton(float viewWidth, float viewHeight)
{
UIView view = new UIView(new RectangleF(0, viewHeight - BUTTONHEIGHT, BUTTONWIDTH, BUTTONHEIGHT));
view.BackgroundColor = UIColor.Clear;
UIButton button = new UIButton(new RectangleF(0, 0, BUTTONWIDTH, BUTTONHEIGHT));
button.SetImage(BACKBUTTONIMAGEOUT, UIControlState.Normal);
button.AdjustsImageWhenDisabled = false;
button.AdjustsImageWhenHighlighted = false;
UILabel backTitle = new UILabel(new RectangleF(50, 10, 60, 25));
backTitle.Text = "返回";
backTitle.TextColor = UIColor.FromRGB(255, 255, 255);
backTitle.Font = UIFont.FromName(FONTFAMILY, 18);
backTitle.TextAlignment = UITextAlignment.Center;
backTitle.BackgroundColor = UIColor.Clear;
button.Add(backTitle);
button.TouchUpInside += (sender, e) =>
{
button.SetImage(BACKBUTTONIMAGEOUT, UIControlState.Normal);
CloseTimePiker();
};
button.TouchDown += (sender, e) =>
{
button.SetImage(BACKBUTTONIMAGEIN, UIControlState.Normal);
};
button.TouchDragInside += (sender, e) =>
{
button.SetImage(BACKBUTTONIMAGEOUT, UIControlState.Normal);
};
view.Add(button);
return view;
}
示例5: GetCustomButton
public static UIView GetCustomButton(float viewWidth, float viewHeight, CustomAlertType type, string message)
{
float width = 300f;
float height = 60f;
float x = (viewWidth - width) / 2;
float y = (viewHeight - height * 1.5f) / 2;
UIView buttonView = new UIView(new RectangleF (x, y, width, height));
buttonView.BackgroundColor = UIColor.Clear;
UIButton alertButton = new UIButton (new RectangleF(0, 0, width, height));
alertButton.BackgroundColor = UIColor.Clear;
alertButton.SetImage(ALERTMESSAGEBACK, UIControlState.Normal);
alertButton.AdjustsImageWhenHighlighted = false;
alertButton.TouchUpInside += (sender, e) =>
{
CloseCustomAlert();
};
UIImageView imageView = new UIImageView(new RectangleF(20, 20, 20, 20));
switch (type)
{
case CustomAlertType.Error: imageView.Image = ALERTMESSAGEERROR; break;
case CustomAlertType.OK:break;
case CustomAlertType.Warning:imageView.Image = ALERTMESSAGEWARNING; break;
case CustomAlertType.Wait:imageView.Image = ALERTMESSAGEWAIT; break;
}
UILabel messageLable = new UILabel();
messageLable.Text = message;
messageLable.Font = UIFont.FromName(FONTFAMILY, 15);
messageLable.TextColor = UIColor.FromRGB(100, 100, 100);
messageLable.Frame = new RectangleF(50, 10, width - 80, height - 20);
messageLable.TextAlignment = UITextAlignment.Left;
messageLable.BackgroundColor = UIColor.Clear;
alertButton.Add(imageView);
alertButton.Add(messageLable);
buttonView.Add(alertButton);
return buttonView;
}
示例6: GetAgreementView
public static UIView GetAgreementView(float viewWidth, float viewHeight)
{
UIView View = new UIView(new RectangleF((viewWidth - 290) / 2, 25, 290, 450));
View.BackgroundColor = UIColor.Clear;
UIImageView backImageView = new UIImageView(new RectangleF(0, 0, 290, 450));
backImageView.Image = AGREEMENTBACKIMAGE;
backImageView.BackgroundColor = UIColor.Clear;
UILabel titleLable = new UILabel(new RectangleF(20, 12, 100, 20));
titleLable.TextAlignment = UITextAlignment.Left;
titleLable.TextColor = UIColor.FromRGB(200, 20, 30);
titleLable.Font = UIFont.FromName(FONTFAMILY, 16);
titleLable.BackgroundColor = UIColor.Clear;
titleLable.Text = "使用协议";
UIWebView textView = new UIWebView(new RectangleF(22, 50, 247, 330));
textView.LoadHtmlString(html, new NSUrl(NSBundle.MainBundle.BundlePath, true));
textView.BackgroundColor = UIColor.FromRGB(250, 250, 250);
UIButton button = new UIButton(new RectangleF(15, 385 , 257, 50));
button.SetImage(AGREEMENTBUTTONOUT, UIControlState.Normal);
button.AdjustsImageWhenHighlighted = false;
UILabel buttonTitle = new UILabel(new RectangleF(100, 0, 60, 50));
buttonTitle.Text = "确定";
buttonTitle.Font = UIFont.FromName(FONTFAMILY, 18);
buttonTitle.TextColor = UIColor.FromRGB(255, 255, 255);
buttonTitle.BackgroundColor = UIColor.Clear;
buttonTitle.TextAlignment = UITextAlignment.Center;
button.Add(buttonTitle);
button.TouchUpInside += (sender, e) =>
{
button.SetImage(AGREEMENTBUTTONIN, UIControlState.Normal);
CloseAgreement();
};
button.TouchDown += (sender, e) =>
{
button.SetImage(AGREEMENTBUTTONIN, UIControlState.Normal);
};
button.TouchDragInside += (sender, e) =>
{
button.SetImage(AGREEMENTBUTTONOUT, UIControlState.Normal);
};
View.Add(backImageView);
View.Add(titleLable);
View.Add(textView);
View.Add(button);
return View;
}
示例7: BuildLayout
private void BuildLayout(){
this.View.BackgroundColor = UIColor.Red;
//- Add Logo
UIImage ideabagLogo = UIImage.FromBundle("Login-Logo").ImageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal);
UIImageView ideabagLogView = new UIImageView (ideabagLogo);
ideabagLogView.Frame = new CoreGraphics.CGRect (97, 31, 184, 294);
this.View.Add (ideabagLogView);
//- Signup Image
UIButton btnSignupImage = new UIButton();
btnSignupImage.Frame = new CoreGraphics.CGRect (194, 313, 150, 50);
UIImage signupImage = UIImage.FromBundle ("btnSignup-unselected").ImageWithRenderingMode (UIImageRenderingMode.AlwaysOriginal);
UIImageView signupImageView = new UIImageView (signupImage);
btnSignupImage.Add (signupImageView);
this.View.Add (btnSignupImage);
//- Username text box and background
UIImageView usernameBackgroundView = new UIImageView(new UIImage (
new CoreImage.CIImage (UIImage.FromBundle ("login-form-background").ImageWithRenderingMode (UIImageRenderingMode.AlwaysOriginal))
));
usernameBackgroundView.Frame = new CoreGraphics.CGRect (0, 366, 380, 50);
UITextField tfUsername = new UITextField (new CoreGraphics.CGRect (16, 376, 343, 30));
tfUsername.Font = UIFont.FromName ("Avenir Book", 17);
tfUsername.Alpha = 1;
tfUsername.BackgroundColor = UIColor.Clear;
tfUsername.TextColor = UIColor.White;
tfUsername.Placeholder = "Email or Username";
this.View.Add (usernameBackgroundView);
this.View.Add (tfUsername);
//- Password text box and background
UIImageView passwordBackgroundView = new UIImageView(new UIImage (
new CoreImage.CIImage (UIImage.FromBundle ("login-form-background").ImageWithRenderingMode (UIImageRenderingMode.AlwaysOriginal))
));
passwordBackgroundView.Frame = new CoreGraphics.CGRect (0, 418, 380, 50);
UITextField tfPassword = new UITextField (
new CoreGraphics.CGRect (16, 428, 343, 30));
tfPassword.Font = UIFont.FromName ("Avenir Book", 17);
tfPassword.Alpha = 1;
tfPassword.BackgroundColor = UIColor.Clear;
tfPassword.TextColor = UIColor.White;
tfPassword.Placeholder = "Password";
this.View.Add (passwordBackgroundView);
this.View.Add (tfPassword);
//- Login Button
UIButton btnLogin = new UIButton(new CoreGraphics.CGRect(59, 479, 256, 49));
btnLogin.Font = UIFont.FromName ("Avenir Book", 22);
btnLogin.BackgroundColor = new UIColor (new CoreGraphics.CGColor (255, 255, 255, 0.85f));
btnLogin.SetTitleShadowColor (UIColor.DarkGray, UIControlState.Normal);
btnLogin.SetTitleColor (UIColor.Red, UIControlState.Normal);
btnLogin.SetTitle ("Login", UIControlState.Normal);
btnLogin.Layer.CornerRadius = 5;
btnLogin.ClipsToBounds = true;
this.View.Add (btnLogin);
//- Forgot password
UIButton btnForgotPassword = new UIButton(new CoreGraphics.CGRect(94,556, 187, 30));
btnForgotPassword.Font = UIFont.FromName ("Avenir Book", 19);
btnForgotPassword.SetTitleColor (UIColor.White, UIControlState.Normal);
btnForgotPassword.SetTitleShadowColor (UIColor.DarkTextColor, UIControlState.Normal);
btnForgotPassword.SetTitle ("Forgot Password?", UIControlState.Normal);
this.View.Add (btnForgotPassword);
//- Facebook login
UIButton btnFacebookLogin = new UIButton(new CoreGraphics.CGRect(73, 623, 228, 32));
btnFacebookLogin.Font = UIFont.FromName ("Avenir Book", 18);
btnFacebookLogin.SetTitle ("Login with Facebook", UIControlState.Normal);
btnFacebookLogin.SetTitleColor (UIColor.White, UIControlState.Normal);
btnFacebookLogin.SetImage (
UIImage.FromBundle ("Facebook-login").ImageWithRenderingMode (UIImageRenderingMode.AlwaysOriginal),
UIControlState.Normal);
this.View.Add (btnFacebookLogin);
}