public static void SetBackButtonImage(this PageRenderer pageRenderer, string path) { if (pageRenderer.NavigationController != null && !pageRenderer.NavigationController.TopViewController.NavigationItem.HidesBackButton && pageRenderer.Element.Navigation.NavigationStack[0] != pageRenderer.Element) { pageRenderer.NavigationController.TopViewController.NavigationItem.SetHidesBackButton(true, false); var backImage = UIImage.FromBundle(path); var customBackButton = new UIButton(UIButtonType.Custom); customBackButton.SetImage(backImage, UIControlState.Normal); customBackButton.SetImage(backImage, UIControlState.Highlighted); customBackButton.Frame = new CoreGraphics.CGRect(0, 0, backImage.Size.Width + navigatigationBarLeftRightPadding, 44); customBackButton.ContentEdgeInsets = new UIEdgeInsets(0, navigatigationBarLeftRightPadding, 0, 0); customBackButton.AddTarget((sender, args) => { var page = ((Page)pageRenderer.Element); if (page.Navigation != null) { page.SendBackButtonPressed(); page.Navigation.PopAsync(true); } }, UIControlEvent.TouchUpInside); var barBackButton = new UIBarButtonItem(customBackButton); // Remove left padding of back button var negativeSeparator = new UIBarButtonItem(UIBarButtonSystemItem.FixedSpace); negativeSeparator.Width = -navigatigationBarLeftRightPadding; pageRenderer.NavigationController.TopViewController.NavigationItem.SetLeftBarButtonItems(new[] { negativeSeparator, barBackButton }, false); } }
protected ViewController(IntPtr handle) : base(handle) { _bambuserView = new BambuserView(BambuserConstants.SessionPresetAuto); _bambuserView.WeakDelegate = this; _bambuserView.ApplicationId = "YOUr-APP-ID"; _bambuserView.BroadcastTitle = "Testing from Xamarin!"; _bambuserView.Author = "GOD"; _bambuserView.Talkback = true; _bambuserView.SetOrientation(InterfaceOrientation, InterfaceOrientation); _bambuserView.EnableArchiveOption(); _bambuserView.EnablePositionOption(); _bambuserView.EnableTalkbackOption(); _bambuserView.EnablePrivateModeOption(); _bambuserView.EnableSaveLocallyOption(); _bambuserView.StartCapture(); _startButton = new UIButton(UIButtonType.RoundedRect); _startButton.SetTitle(START_TITLE, UIControlState.Normal); _startButton.AddTarget(StartButton_TouchUpInside, UIControlEvent.TouchUpInside); _settingsButton = new UIButton(UIButtonType.RoundedRect); _settingsButton.SetTitle("Seetings", UIControlState.Normal); _settingsButton.AddTarget(SettingsButton_TouchUpInside, UIControlEvent.TouchUpInside); _logView = new UITextView(new RectangleF(0, (float)UIScreen.MainScreen.Bounds.Height - 300, (float)UIScreen.MainScreen.Bounds.Width, 300)) { Editable = false }; _httpClient = new HttpClient(); }
public override void ViewDidLoad() { base.ViewDidLoad(); profileType = ProfileType.ListGroupMembers; Title = ""; NavigationController.NavigationBar.TitleTextAttributes = new UIStringAttributes { ForegroundColor = UIColor.FromRGB(90, 89, 89) }; groupProfileBtn = new UIButton(UIButtonType.System); groupProfileBtn.Frame = new CGRect(0, 0, 100, 40); groupProfileBtn.BackgroundColor = UIColor.White; groupProfileBtn.SetTitleColor(UIColor.FromRGB(90, 89, 89), UIControlState.Normal); //groupProfileBtn.ImageView.ContentMode = UIViewContentMode.ScaleAspectFill; //groupProfileBtn.ImageView.Layer.CornerRadius = 22; //groupProfileBtn.ImageView.Layer.MasksToBounds = true; //groupProfileBtn.ImageView.Layer.Frame = new CGRect(0, 0, 44, 44); groupProfileBtn.SetImage(UIImage.FromBundle("MyGroup"), UIControlState.Normal); //Utils.SetImageFromNSUrlSession(groupProfilePicture, groupProfileBtn.ImageView, this, PictureType.Profile); groupProfileBtn.SetTitle("View Group Details", UIControlState.Normal); groupProfileBtn.TitleEdgeInsets = new UIEdgeInsets(0, groupProfileBtn.ImageView.Frame.Size.Width / 4, 0, -groupProfileBtn.ImageView.Frame.Size.Width); groupProfileBtn.ImageEdgeInsets = new UIEdgeInsets(0, -groupProfileBtn.TitleLabel.Frame.Size.Width / 4, 0, groupProfileBtn.TitleLabel.Frame.Size.Width); groupProfileBtn.AddTarget(Self, new ObjCRuntime.Selector("GroupProfileBtn:"), UIControlEvent.TouchUpInside); NavigationItem.TitleView = groupProfileBtn; BTProgressHUD.Show(null, -1, ProgressHUD.MaskType.Clear); fetchTableItems(); }
void loadIPadLayout() { CGSize desiredSize = CGSize.Empty; if (sections.Count == 0 && options.Count == 1) { UIButton button = new UIButton(UIButtonType.RoundedRect); button.SetTitle(options [0].OptionText, UIControlState.Normal); button.AddTarget(optionTouched, UIControlEvent.TouchUpInside); desiredSize = button.SizeThatFits(this.View.Bounds.Size); button.Frame = new CGRect(30, 10, desiredSize.Width, desiredSize.Height); this.View.AddSubview(button); } else if (options.Count >= 3 || sections.Count > 0) { settingsButton = new UIBarButtonItem(new UIImage("menu.png"), UIBarButtonItemStyle.Plain, settingsTouched); this.NavigationItem.RightBarButtonItem = settingsButton; } else { UISegmentedControl segmented = new UISegmentedControl(); for (int i = 0; i < options.Count; i++) { segmented.InsertSegment(options [i].OptionText, i + 1, false); } desiredSize = segmented.SizeThatFits(this.View.Bounds.Size); segmented.Frame = new CGRect(10, 10, desiredSize.Width, desiredSize.Height); segmented.AddTarget(optionTouched, UIControlEvent.ValueChanged); this.View.AddSubview(segmented); segmented.SelectedSegment = this.SelectedOption; } exampleBounds = new CGRect(20, 30 + desiredSize.Height, this.View.Bounds.Size.Width - 40, this.View.Bounds.Size.Height - desiredSize.Height - 60); }
public void AddSiteUrl(RectangleF frame) { url = UIButton.FromType(UIButtonType.Custom); url.LineBreakMode = UILineBreakMode.TailTruncation; url.HorizontalAlignment = UIControlContentHorizontalAlignment.Left; url.TitleShadowOffset = new SizeF(0, 1); url.SetTitleColor(UIColor.FromRGB (0x32, 0x4f, 0x85), UIControlState.Normal); url.SetTitleColor(UIColor.Red, UIControlState.Highlighted); url.SetTitleShadowColor(UIColor.White, UIControlState.Normal); url.AddTarget(delegate { if (UrlTapped != null) UrlTapped (); }, UIControlEvent.TouchUpInside); // Autosize the bio URL to fit available space var size = _urlSize; var urlFont = UIFont.BoldSystemFontOfSize(size); var urlSize = new NSString(_bio.Url).StringSize(urlFont); var available = Util.IsPad() ? 400 : 185; // Util.IsRetina() ? 185 : 250; while(urlSize.Width > available) { urlFont = UIFont.BoldSystemFontOfSize(size--); urlSize = new NSString(_bio.Url).StringSize(urlFont); } url.Font = urlFont; url.Frame = new RectangleF ((float)_left, (float)70, (float)(frame.Width - _left), (float)size); url.SetTitle(_bio.Url, UIControlState.Normal); url.SetTitle(_bio.Url, UIControlState.Highlighted); AddSubview(url); }
void PlaceFlashButton() { CGSize screenSize = UIScreen.MainScreen.Bounds.Size; CGRect buttonFrame = new CGRect(screenSize.Width - 80, screenSize.Height - 100, 40, 40); if (flashButton == null) { flashButton = new UIButton(buttonFrame); flashButton.AddTarget(delegate { scannerViewController.CameraSession.TorchLightEnabled = !scannerViewController.CameraSession.TorchLightEnabled; flashButton.Selected = scannerViewController.CameraSession.TorchLightEnabled; }, UIControlEvent.TouchUpInside); flashButton.SetImage(UIImage.FromBundle("ui_flash_off"), UIControlState.Normal); flashButton.SetImage(UIImage.FromBundle("ui_flash_on"), UIControlState.Selected); flashButton.Selected = scannerViewController.CameraSession.TorchLightEnabled; } else { flashButton.Frame = buttonFrame; } View.AddSubview(flashButton); View.BringSubviewToFront(flashButton); }
private UIView CreateCancelView(ActionSheetOption option = null) { var button = new UIButton(UIButtonType.Custom) { BackgroundColor = UIColor.Clear, AutoresizingMask = UIViewAutoresizing.All, HorizontalAlignment = UIControlContentHorizontalAlignment.Right, TitleEdgeInsets = new UIEdgeInsets(0, 0, 0, 30) }; button.SetTitle(string.IsNullOrEmpty(option?.Text) ? "Cancel" : option.Text, UIControlState.Normal); button.SetTitleColor(ButtonTextUiColor, UIControlState.Normal); button.AddTarget((x, y) => { try { option?.Action?.Invoke(); } catch (Exception ex) { Console.WriteLine(ex); } finally { DismissController(); } }, UIControlEvent.TouchUpInside); button.HeightAnchor.ConstraintEqualTo(RowHeight).Active = true; return(button); }
public override void ViewDidLoad() { base.ViewDidLoad(); // Perform custom UI setup here cameraButton = new UIButton(UIButtonType.System); galleryButton = new UIButton(UIButtonType.System); cameraButton.SetTitle("Camera", UIControlState.Normal); cameraButton.SizeToFit(); cameraButton.TranslatesAutoresizingMaskIntoConstraints = false; cameraButton.AddTarget(cameraButton_click, UIControlEvent.TouchDown); View.AddSubview(cameraButton); var cameraAlignment = NSLayoutConstraint.Create(cameraButton, NSLayoutAttribute.CenterXWithinMargins, NSLayoutRelation.Equal, View, NSLayoutAttribute.CenterXWithinMargins, 1.0f, 0.0f); View.AddConstraints(new[] { cameraAlignment }); imageView = new UIImageView(new CGRect(10, 150, 300, 300)); Add(imageView); galleryButton.SetTitle("Gallery", UIControlState.Normal); galleryButton.SizeToFit(); galleryButton.TranslatesAutoresizingMaskIntoConstraints = false; galleryButton.AddTarget(galleryButton_click, UIControlEvent.TouchDown); View.AddSubview(galleryButton); View.Add(galleryButton); var galleryAlignment = NSLayoutConstraint.Create(galleryButton, NSLayoutAttribute.LeftMargin, NSLayoutRelation.Equal, View, NSLayoutAttribute.LeftMargin, 1.0f, 0.0f); var gallerycenterAlignment = NSLayoutConstraint.Create(cameraButton, NSLayoutAttribute.CenterXWithinMargins, NSLayoutRelation.Equal, View, NSLayoutAttribute.CenterXWithinMargins, 1.0f, 0.0f); View.AddConstraints(new[] { galleryAlignment, gallerycenterAlignment }); }
public void AddSiteUrl(RectangleF frame) { url = UIButton.FromType(UIButtonType.Custom); url.LineBreakMode = UILineBreakMode.TailTruncation; url.HorizontalAlignment = UIControlContentHorizontalAlignment.Left; url.TitleShadowOffset = new SizeF(0, 1); url.SetTitleColor(UIColor.FromRGB(0x32, 0x4f, 0x85), UIControlState.Normal); url.SetTitleColor(UIColor.Red, UIControlState.Highlighted); url.SetTitleShadowColor(UIColor.White, UIControlState.Normal); url.AddTarget(delegate { if (UrlTapped != null) { UrlTapped(); } }, UIControlEvent.TouchUpInside); // Autosize the bio URL to fit available space var size = _urlSize; var urlFont = UIFont.BoldSystemFontOfSize(size); var urlSize = new NSString(_bio.Url).StringSize(urlFont); var available = Util.IsPad() ? 400 : 185; // Util.IsRetina() ? 185 : 250; while (urlSize.Width > available) { urlFont = UIFont.BoldSystemFontOfSize(size--); urlSize = new NSString(_bio.Url).StringSize(urlFont); } url.Font = urlFont; url.Frame = new RectangleF((float)_left, (float)70, (float)(frame.Width - _left), (float)size); url.SetTitle(_bio.Url, UIControlState.Normal); url.SetTitle(_bio.Url, UIControlState.Highlighted); AddSubview(url); }
public override void ViewDidLoad() { base.ViewDidLoad(); SetupMainButton(); // Perform custom UI setup here nextKeyboardButton = new UIButton(UIButtonType.System); nextKeyboardButton.SetTitle("Next Keyboard", UIControlState.Normal); nextKeyboardButton.SizeToFit(); nextKeyboardButton.TranslatesAutoresizingMaskIntoConstraints = false; nextKeyboardButton.AddTarget(this, new Selector("advanceToNextInputMode"), UIControlEvent.TouchUpInside); View.AddSubview(nextKeyboardButton); var nextKeyboardButtonLeftSideConstraint = NSLayoutConstraint.Create(nextKeyboardButton, NSLayoutAttribute.Left, NSLayoutRelation.Equal, View, NSLayoutAttribute.Left, 1.0f, 10.0f); var nextKeyboardButtonBottomConstraint = NSLayoutConstraint.Create(nextKeyboardButton, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, View, NSLayoutAttribute.Bottom, 1.0f, 0.0f); View.AddConstraints(new [] { nextKeyboardButtonLeftSideConstraint, nextKeyboardButtonBottomConstraint }); }
private UIBarButtonItem GetNotificationsButton() { var composeButton = new UIButton(new RectangleF(0, 0, 24, 24)); composeButton.SetBackgroundImage(UIImage.FromBundle("Notification"), UIControlState.Normal); composeButton.AddTarget((sender, args) => { var notificationsController = this.Storyboard.InstantiateViewController("NotificationsController") as NotificationsController; this.NavigationController.PushViewController(notificationsController, true); }, UIControlEvent.TouchUpInside); // Notifications Badge nfloat badgeSize = 16; nfloat badgeOriginX = 12; // Half of the icon width nfloat badgeOriginY = -6; this.badge = new UILabel(); this.badge.TextColor = UIColor.White; this.badge.BackgroundColor = UIColor.Red; this.badge.Font = UIFont.SystemFontOfSize(11); this.badge.TextAlignment = UITextAlignment.Center; this.badge.Frame = CoreGraphics.CGRect.FromLTRB(badgeOriginX, badgeOriginY, badgeOriginX + badgeSize, badgeOriginY + badgeSize); this.badge.Layer.CornerRadius = badgeSize / 2; this.badge.Layer.MasksToBounds = true; this.badge.Layer.BorderWidth = 1; this.badge.Layer.BorderColor = UIColor.White.CGColor; return(new UIBarButtonItem(composeButton)); }
private void InitializeJoinClass() { Title1 = new UITextView(); Title1.Text = "Enter Room Code"; Title1.Frame = new CGRect(0, 0, Frame.Width, 48); Title1.Font = Fonts.Settings_Title; Title1.BackgroundColor = UIColor.Clear; Title1.TextAlignment = UITextAlignment.Center; Title1.Editable = false; Title1.UserInteractionEnabled = false; CodeView = new UITextField(); CodeView.Frame = new CGRect(16, Frame.Height / 3, 196, 64); CodeView.Font = Fonts.Settings_Title; CodeView.KeyboardType = UIKeyboardType.NumberPad; CodeView.Layer.BorderColor = UIColor.White.CGColor; CodeView.Layer.BorderWidth = 1; CodeView.Font = Fonts.Big; CodeView.TouchUpInside += (sender, e) => { CodeView.Layer.BorderColor = UIColor.White.CGColor; }; SubmitArrow = new UIButton(); SubmitArrow.Frame = new CGRect(196, Frame.Height / 3, 64, 64); SubmitArrow.SetImage(UIImage.FromBundle("button_submit"), UIControlState.Normal); SubmitArrow.AddTarget(this, new Selector("FindRoom"), UIControlEvent.TouchUpInside); SubmitArrow.ContentMode = UIViewContentMode.ScaleAspectFit; Cancel.Frame = new CGRect(Frame.Width - 32, 0, 32, 32); }
private void SetupUI() { var backButton = new UIButton(new RectangleF(0, 0, 25, 25)); backButton.SetBackgroundImage(UIImage.FromFile("Images/General/BackButton.png"), UIControlState.Normal); backButton.SetBackgroundImage(UIImage.FromFile("Images/General/BackButtonHighlighted.png"), UIControlState.Highlighted); backButton.AddTarget((object sender, EventArgs args) => NavigationController.PopViewControllerAnimated(true), UIControlEvent.TouchUpInside); var cancelButton = new UIButton(new RectangleF(0, 0, 25, 25)); cancelButton.SetBackgroundImage(UIImage.FromFile(Images.CancelButton), UIControlState.Normal); cancelButton.SetBackgroundImage(UIImage.FromFile(Images.CancelButtonHighlighted), UIControlState.Highlighted); cancelButton.AddTarget(HandleCancelButtonTapped, UIControlEvent.TouchUpInside); BackButton = new UIBarButtonItem(backButton); CancelButton = new UIBarButtonItem(cancelButton); NavigationController.NavigationItem.BackBarButtonItem = BackButton; NavigationItem.LeftBarButtonItem = CancelButton; NavigationController.NavigationBar.BarStyle = UIBarStyle.Black; NavigationBarLabel = InterfaceHelper.LabelForTitle("SETTINGS"); TableView.BackgroundView = null; TableView.BackgroundColor = UIColor.FromPatternImage(UIImage.FromFile("Images/General/TableBackground.png")); }
public override void ViewDidAppear(bool animated) { base.ViewDidAppear(animated); // Creates image of the Button UIImage imageAppButtonButton = UIImage.FromFile("fab"); // Creates a Button var appButton = new UIButton(UIButtonType.Custom); // Sets width and height to the Button appButton.Frame = new CGRect(0.0f, 0.0f, imageAppButtonButton.Size.Width, imageAppButtonButton.Size.Height); // Sets image to the Button appButton.SetBackgroundImage(imageAppButtonButton, UIControlState.Normal); // Sets the center of the Button to the center of the TabBar. //How to set the center of the button depends if the image is circular and its height is bigger than the tabBar nfloat heightDifference = imageAppButtonButton.Size.Height - this.TabBar.Frame.Size.Height; //if(heightDifference < 0) // cameraButton.Center = TabBar.Center; //else //{ // CGPoint center = TabBar.Center; // center.Y = (center.Y - heightDifference / 2.0f); // cameraButton.Center = center; //} CGPoint center = TabBar.Center; center.Y = 820f; appButton.Center = center; // Sets an action to the Button var eventHandler = new EventHandler(DoSomething); appButton.AddTarget(eventHandler, events: UIControlEvent.TouchUpInside); //Create shadow effect appButton.Layer.ShadowColor = UIColor.Black.CGColor; appButton.Layer.ShadowOffset = new CGSize(width: 0.0, height: 5.0); appButton.Layer.ShadowOpacity = 0.5f; appButton.Layer.ShadowRadius = 2.0f; appButton.Layer.MasksToBounds = false; // Adds the Button to the view View.AddSubview(appButton); TabBar.ItemSpacing = 4f; TabBar.BarTintColor = UIColor.White; TabBar.BackgroundColor = UIColor.White; TabBar.TintColor = UIColor.Blue; //Apply this for dark mode //TabBar.BarStyle = UIBarStyle.Black; var items = TabBar.Items; var item1 = items[1]; var item2 = items[2]; item1.TitlePositionAdjustment = new UIOffset(-20f, 0f); item2.TitlePositionAdjustment = new UIOffset(20f, 0f); //Remove the top line TabBar.ShadowImage = new UIImage(); TabBar.BackgroundImage = new UIImage(); TabBar.ClipsToBounds = true; }
protected ViewController(IntPtr handle) : base(handle) { _logView = new UITextView(new RectangleF(0, (float)UIScreen.MainScreen.Bounds.Height - 300, (float)UIScreen.MainScreen.Bounds.Width, 300)) { Editable = false }; _player = new BambuserPlayer(); _player.WeakDelegate = this; _player.ApplicationId = "YOUT-API-ID"; _resourceUri = "https://cdn.bambuser.net/broadcasts/57e8b843-a6b9-451d-9f1f-621c2dcb9bcc?da_id=cbf70495-232a-c827-e5ff-681104245155&da_timestamp=1606780800000&da_nonce=0.1&da_signature_method=HMAC-SHA256&da_signature=3dacb0b640c405a35236b21a4dbb5e6a5647aa1b228b3f91699020803e000756"; _playButton = new UIButton(UIButtonType.System); _playButton.SetTitle("Play", UIControlState.Normal); _playButton.AddTarget((sender, e) => { _player.PlayVideo(_resourceUri); }, UIControlEvent.TouchUpInside); _pauseButton = new UIButton(UIButtonType.System); _pauseButton.SetTitle("Pause", UIControlState.Normal); _pauseButton.AddTarget((sender, e) => { _player.PauseVideo(); }, UIControlEvent.TouchUpInside); _rewindButton = new UIButton(UIButtonType.System); _rewindButton.SetTitle("Rewind", UIControlState.Normal); _rewindButton.AddTarget((sender, e) => { _player.SeekTo(0.0); }, UIControlEvent.TouchUpInside); }
public override void ViewDidLoad() { base.ViewDidLoad(); // Perform any additional setup after loading the view, typically from a nib. UIFont aboutBold = UIFont.FromDescriptor(UIFontDescriptor.PreferredTitle1.CreateWithTraits(UIFontDescriptorSymbolicTraits.Bold), 0); this.About.Font = UIFontMetrics.DefaultMetrics.GetScaledFont(aboutBold); NavigationControllerUtil.SetNavigationBarAttributes(this.NavigationController.NavigationBar); NavigationControllerUtil.SetNavigationTitle(this.NavigationItem, Constants.ApplicationName); //Programmatically add a back button and an arrow UIImage backArrowImage = UIImage.FromBundle("back-arrow"); UIButton backButton = new UIButton(UIButtonType.Custom); backButton.SetImage(backArrowImage, UIControlState.Normal); backButton.SetTitle("Back", UIControlState.Normal); backButton.ImageEdgeInsets = new UIEdgeInsets(0.0f, -12.5f, 0.0f, 0.0f); backButton.AddTarget((sender, e) => { this.NavigationController?.PopViewController(true); }, UIControlEvent.TouchUpInside); this.NavigationItem.LeftBarButtonItem = new UIBarButtonItem(backButton); // Programatically set version number this.Version.Text = "Version " + Constants.VersionNumber; //set the initial focus element UIAccessibility.PostNotification(UIAccessibilityPostNotification.ScreenChanged, About); }
public override void ViewDidLoad() { base.ViewDidLoad(); containerView = new UIView() { Frame = new CoreGraphics.CGRect(0, View.Frame.Height, View.Frame.Width, 0), BackgroundColor = UIColor.Purple }; zz = new UIButton { //Frame = new CoreGraphics.CGRect(View.Frame.Width - 45, this.containerView.Frame.Y - 45, 40, 20), TranslatesAutoresizingMaskIntoConstraints = false }; View.AddSubview(containerView); View.AddSubview(zz); zz.RightAnchor.ConstraintEqualTo(View.RightAnchor, new nfloat(-5)).Active = true; zz.BottomAnchor.ConstraintEqualTo(TabBar.BottomAnchor, new nfloat(-10)).Active = true; zz.WidthAnchor.ConstraintEqualTo(40).Active = true; zz.HeightAnchor.ConstraintEqualTo(25).Active = true; zz.SetBackgroundImage(new UIImage("arrow"), UIControlState.Normal); //containerView.Frame = new CoreGraphics.CGRect(0, View.Frame.Height, View.Frame.Width, 0); //zz.Frame = new CoreGraphics.CGRect(View.Frame.Width - 45, this.View.Frame.Height - 45, 40, 20); containerView.Hidden = true; zz.AddTarget(HandleEventHandler, UIControlEvent.TouchUpInside); }
public override void ViewDidLoad() { base.ViewDidLoad(); var button = new UIButton(UIButtonType.System); button.Frame = new CGRect(20, this.View.Center.Y - 22, this.View.Frame.Width - 40, 44); button.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleTopMargin | UIViewAutoresizing.FlexibleBottomMargin; button.SetTitle("Load 10000 items", UIControlState.Normal); button.AddTarget((object sender, EventArgs e) => { int systemVersion = int.Parse(UIDevice.CurrentDevice.SystemVersion.Split('.')[0]); if (systemVersion < 9) { var alert = new TKAlert(); alert.Title = "Telerik UI"; alert.Message = "TKListView is optimized for performance when using dynamic item sizing only when running on iOS 9 and upper!"; alert.AddAction(new TKAlertAction("OK", (TKAlert arg1, TKAlertAction arg2) => { this.CreateListView(); return(true); })); alert.Show(true); } else { this.CreateListView(); } ((UIView)sender).RemoveFromSuperview(); }, UIControlEvent.TouchUpInside); this.View.AddSubview(button); }
public override void ViewDidLoad() { base.ViewDidLoad (); var button = new UIButton (UIButtonType.System); button.Frame = new CGRect(20, this.View.Center.Y - 22, this.View.Frame.Width-40, 44); button.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleTopMargin | UIViewAutoresizing.FlexibleBottomMargin; button.SetTitle ("Load 10000 items", UIControlState.Normal); button.AddTarget ((object sender, EventArgs e) => { int systemVersion = int.Parse(UIDevice.CurrentDevice.SystemVersion.Split('.')[0]); if (systemVersion < 9) { var alert = new TKAlert(); alert.Title = "Telerik UI"; alert.Message = "TKListView is optimized for performance when using dynamic item sizing only when running on iOS 9 and upper!"; alert.AddAction(new TKAlertAction("OK", (TKAlert arg1, TKAlertAction arg2) => { this.CreateListView(); return true; })); alert.Show(true); } else { this.CreateListView(); } ((UIView)sender).RemoveFromSuperview(); }, UIControlEvent.TouchUpInside); this.View.AddSubview(button); }
// Used to update asynchronously our display when we get enough information about the tweet detail public void UpdateFromUserId(long userId) { user = User.FromId(userId); if (user == null) { Console.WriteLine("Could nto find user ID={0}", userId); return; } var pic = ImageStore.RequestProfilePicture(-userId, user.PicUrl, this); if (pic != ImageStore.DefaultImage) { profilePic.Image = pic; } url.AddTarget(delegate { if (UrlTapped != null) { UrlTapped(); } }, UIControlEvent.TouchUpInside); url.SetTitle(user.Url, UIControlState.Normal); url.SetTitle(user.Url, UIControlState.Highlighted); SetNeedsDisplay(); }
public override void ViewDidLoad() { base.ViewDidLoad(); this.View.BackgroundColor = UIColor.White; this.reservationForm = new ReservationForm(); this.dataSource = new TKDataFormEntityDataSourceHelper(this.reservationForm); this.dataFormDelegate = new CustomizationDataFormDelegate(); NSDateFormatter formatter = new NSDateFormatter(); formatter.DateFormat = "h:mm a"; this.dataSource.PropertyWithName("Time").Formatter = formatter; this.dataSource["Name"].Image = new UIImage("guest-name.png"); this.dataSource["Phone"].Image = new UIImage("phone.png"); this.dataSource["Date"].Image = new UIImage("calendar.png"); this.dataSource["Time"].Image = new UIImage("time.png"); this.dataSource["Guests"].Image = new UIImage("guest-number.png"); this.dataSource["Table"].Image = new UIImage("table-number.png"); this.dataSource["Name"].HintText = "Name"; this.dataSource["Name"].ErrorMessage = @"Please fill in the guest name"; this.dataSource["Time"].EditorClass = new ObjCRuntime.Class(typeof(TKDataFormTimePickerEditor)); this.dataSource["Phone"].EditorClass = new ObjCRuntime.Class(typeof(CallEditor)); this.dataSource ["Phone"].HintText = "Phone"; this.dataSource["Origin"].EditorClass = new ObjCRuntime.Class(typeof(TKDataFormSegmentedEditor)); this.dataSource["Guests"].ValuesProvider = new TKRange(new NSNumber(1), new NSNumber(10)); this.dataSource["Section"].ValuesProvider = NSArray.FromStrings(new string[] { "Section 1", "Section 2", "Section 3", "Section 4" }); this.dataSource["Table"].ValuesProvider = NSArray.FromStrings(new string[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15" }); this.dataSource["Origin"].ValuesProvider = NSArray.FromStrings(new string[] { "phone", "in-person", "online", "other" }); this.dataSource.AddGroup("RESERVATION DETAILS", new string[] { "Name", "Phone", "Date", "Time", "Guests" }); this.dataSource.AddGroup("TABLE DETAILS", new string[] { "Section", "Table" }); this.dataSource.AddGroup("ORIGIN", new string[] { "Origin" }); this.DataForm.BackgroundColor = UIColor.FromPatternImage(new UIImage("wood-pattern.png")); this.DataForm.Frame = new CGRect(0, 0, this.View.Bounds.Size.Width, this.View.Bounds.Size.Height - 66); this.DataForm.TintColor = new UIColor(0.780f, 0.2f, 0.223f, 1.0f); this.DataForm.Delegate = this.dataFormDelegate; this.DataForm.WeakDataSource = this.dataSource.NativeObject; btn = new UIButton(new CGRect(0, this.DataForm.Frame.Size.Height, this.View.Bounds.Size.Width, 66)); btn.SetTitle("Cancel Reservation", UIControlState.Normal); btn.SetTitleColor(new UIColor(0.780f, 0.2f, 0.223f, 1.0f), UIControlState.Normal); btn.AddTarget(this, new ObjCRuntime.Selector("CancelReservation"), UIControlEvent.TouchUpInside); this.View.AddSubview(btn); }
public UIButton CreateBackButton(int leftCapWidth) { backButtonCapWidth = leftCapWidth; UIImage buttonImage = UIImage.FromBundle("Images/gallery/backButton.png").StretchableImage(backButtonCapWidth, 0); UIImage buttonHighlightImage = UIImage.FromBundle("Images/gallery/backButtonHighlighted.png").StretchableImage(backButtonCapWidth, 0); UIButton button = UIButton.FromType(UIButtonType.Custom); button.TitleLabel.Font = UIFont.BoldSystemFontOfSize(UIFont.SmallSystemFontSize); button.TitleLabel.TextColor = UIColor.White; button.TitleLabel.ShadowOffset = new SizeF(0, -1); button.TitleLabel.ShadowColor = UIColor.DarkGray; button.TitleLabel.LineBreakMode = UILineBreakMode.TailTruncation; button.TitleEdgeInsets = new UIEdgeInsets(0, 6.0f, 0, 3.0f); button.Frame = new RectangleF(0, 0, 0, buttonImage.Size.Height); SetBackButtonText(button); // Set the stretchable images as the background for the button button.SetBackgroundImage(buttonImage, UIControlState.Normal); button.SetBackgroundImage(buttonHighlightImage, UIControlState.Highlighted); button.SetBackgroundImage(buttonHighlightImage, UIControlState.Selected); button.AddTarget(delegate { _navigationController.PopViewControllerAnimated(true); }, UIControlEvent.TouchUpInside); buttonImage.Dispose(); buttonHighlightImage.Dispose(); return(button); }
private void SetNavigationBar() { var leftBarButton = new UIButton(); leftBarButton.SetImage(UIImage.FromBundle("ic_back_arrow"), UIControlState.Normal); leftBarButton.SetTitle(AppSettings.LocalizationManager.GetText(LocalizationKeys.PlagiarismTitle), UIControlState.Normal); leftBarButton.ImageEdgeInsets = new UIEdgeInsets(0, 0, 0, 20); leftBarButton.TitleEdgeInsets = new UIEdgeInsets(0, 20, 0, -20); leftBarButton.SetTitleColor(UIColor.Black, UIControlState.Normal); leftBarButton.TitleLabel.Font = Constants.Semibold16; leftBarButton.TitleLabel.TextColor = Constants.R15G24B30; leftBarButton.AddTarget(GoBack, UIControlEvent.TouchDown); leftBarButton.SizeToFit(); NavigationItem.LeftBarButtonItem = new UIBarButtonItem(leftBarButton); var guidelines = new UIBarButtonItem(AppSettings.LocalizationManager.GetText(LocalizationKeys.GuidelinesForPlagiarism), UIBarButtonItemStyle.Plain, OpenGuidelines); var textAttributes = new UITextAttributes(); textAttributes.Font = Constants.Semibold14; textAttributes.TextColor = Constants.R255G34B5; guidelines.SetTitleTextAttributes(textAttributes, UIControlState.Normal); guidelines.SetTitleTextAttributes(textAttributes, UIControlState.Selected); NavigationItem.RightBarButtonItem = guidelines; NavigationController.NavigationBar.TintColor = Constants.R15G24B30; NavigationController.NavigationBar.Translucent = false; }
private void Setup() { //Label autocompleteLabel = new UILabel(CGRect.Empty); autocompleteLabel.Font = this.Font; autocompleteLabel.BackgroundColor = UIColor.Clear; autocompleteLabel.TextColor = UIColor.LightGray; autocompleteLabel.LineBreakMode = UILineBreakMode.Clip; autocompleteLabel.Hidden = true; this.AddSubview(autocompleteLabel); this.BringSubviewToFront(autocompleteLabel); //Button autocompleteButton = new UIButton(UIButtonType.Custom); autocompleteButton.AddTarget(OnButtonCliced, UIControlEvent.TouchUpInside); autocompleteButton.SetImage(UIImage.FromBundle("autocompleteButton"), UIControlState.Normal); this.AddSubview(autocompleteButton); this.BringSubviewToFront(autocompleteButton); autocompleteString = string.Empty; NSNotificationCenter.DefaultCenter.AddObserver((NSString)UITextFieldTextDidChangeNotification, OnUITextFieldTextDidChangeNotification); }
public override void TouchesEnded(NSSet touches, UIEvent evt) { if (string.IsNullOrEmpty(_disabled) && !_confirmed) { var point = (touches.AnyObject as UITouch).LocationInView(this.Superview); if (!Frame.Contains(point)) { Lighten(); base.TouchesCancelled(touches, evt); } else if (Selected) { Lighten(); _confirmed = true; _cancelOverlay.RemoveFromSuperview(); _cancelOverlay = null; base.TouchesEnded(touches, evt); } else { Lighten(); Selected = true; _cancelOverlay = UIButton.FromType(UIButtonType.Custom); _cancelOverlay.Frame = new RectangleF(0, 0, 1024, 1024); _cancelOverlay.AddTarget(delegate { Cancel(); }, UIControlEvent.TouchDown); Superview.AddSubview(_cancelOverlay); Superview.BringSubviewToFront(this); } } }
/// <summary> /// Create a button for the specified command and with the title color. /// The button is used as the accessory view of the table cell. /// </summary> private UIButton NewAccessoryView(Command cellCommand, UIColor titleColor) { var transferCount = 0; // Retrieve the transfer count for the command. if (cellCommand == Command.TransferFile) { transferCount = WCSession.DefaultSession.OutstandingFileTransfers?.Length ?? 0; } else if (cellCommand == Command.TransferUserInfo) { transferCount = WCSession.DefaultSession.OutstandingUserInfoTransfers?.Count(transfer => !transfer.CurrentComplicationInfo) ?? 0; } else if (cellCommand == Command.TransferCurrentComplicationUserInfo) { transferCount = WCSession.DefaultSession.OutstandingUserInfoTransfers?.Count(transfer => transfer.CurrentComplicationInfo) ?? 0; } // Create and configure the button. var button = new UIButton(UIButtonType.RoundedRect); button.AddTarget((sender, args) => this.ShowTransfers(sender as UIButton), UIControlEvent.TouchUpInside); button.SetTitleColor(titleColor, UIControlState.Normal); button.SetTitle($" {transferCount} ", UIControlState.Normal); button.SizeToFit(); return(button); }
public override void ViewDidLoad() { base.ViewDidLoad(); // Perform any additional setup after loading the view, typically from a nib. mapView = new NMapView(View.Frame); NavigationController.NavigationBar.Translucent = false; // set the delegate for map view mapView.WeakDelegate = this; // set the application api key for Open MapViewer Library //[self.mapView setClientId:@"YOUR CLIENT ID"]; mapView.SetClientId(AppSetting.CLIENT_ID); mapView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight; View.AddSubview(mapView); currentState = State.Disabled; UIButton button = new UIButton(new CGRect(15, 30, 36, 36)); var image = UIImage.FromBundle("v4_btn_navi_location_normal"); button.SetImage(image, UIControlState.Normal); button.AddTarget(buttonClicked, UIControlEvent.TouchUpInside); changeStateButton = button; View.AddSubview(button); }
public override void ViewDidLoad() { base.ViewDidLoad (); this.View.BackgroundColor = UIColor.White; this.reservationForm = new ReservationForm (); this.dataSource = new TKDataFormEntityDataSourceHelper (this.reservationForm); this.dataFormDelegate = new CustomizationDataFormDelegate (); NSDateFormatter formatter = new NSDateFormatter (); formatter.DateFormat = "h:mm a"; this.dataSource.PropertyWithName ("Time").Formatter = formatter; this.dataSource["Name"].Image = new UIImage ("guest-name.png"); this.dataSource["Phone"].Image = new UIImage ("phone.png"); this.dataSource["Date"].Image = new UIImage ("calendar.png"); this.dataSource["Time"].Image = new UIImage ("time.png"); this.dataSource["Guests"].Image = new UIImage ("guest-number.png"); this.dataSource["Table"].Image = new UIImage ("table-number.png"); this.dataSource["Name"].HintText = "Name"; this.dataSource["Name"].ErrorMessage = @"Please fill in the guest name"; this.dataSource["Time"].EditorClass = new ObjCRuntime.Class(typeof(TKDataFormTimePickerEditor)); this.dataSource["Phone"].EditorClass = new ObjCRuntime.Class(typeof(CallEditor)); this.dataSource ["Phone"].HintText = "Phone"; this.dataSource["Origin"].EditorClass = new ObjCRuntime.Class(typeof(TKDataFormSegmentedEditor)); this.dataSource["Guests"].ValuesProvider = new TKRange (new NSNumber(1), new NSNumber(10)); this.dataSource["Section"].ValuesProvider = NSArray.FromStrings (new string[] { "Section 1", "Section 2", "Section 3", "Section 4" }); this.dataSource["Table"].ValuesProvider = NSArray.FromStrings(new string[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15" }); this.dataSource["Origin"].ValuesProvider = NSArray.FromStrings (new string[] { "phone", "in-person", "online", "other" }); this.dataSource.AddGroup ("RESERVATION DETAILS", new string[] { "Name", "Phone", "Date", "Time", "Guests" }); this.dataSource.AddGroup ("TABLE DETAILS", new string[] { "Section", "Table" }); this.dataSource.AddGroup ("ORIGIN", new string[] { "Origin" }); this.DataForm.BackgroundColor = UIColor.FromPatternImage (new UIImage ("wood-pattern.png")); this.DataForm.Frame = new CGRect (0, 0, this.View.Bounds.Size.Width, this.View.Bounds.Size.Height - 66); this.DataForm.TintColor = new UIColor (0.780f, 0.2f, 0.223f, 1.0f); this.DataForm.Delegate = this.dataFormDelegate; this.DataForm.WeakDataSource = this.dataSource.NativeObject; btn = new UIButton (new CGRect (0, this.DataForm.Frame.Size.Height, this.View.Bounds.Size.Width, 66)); btn.SetTitle ("Cancel Reservation", UIControlState.Normal); btn.SetTitleColor (new UIColor (0.780f, 0.2f, 0.223f, 1.0f), UIControlState.Normal); btn.AddTarget (this, new ObjCRuntime.Selector ("CancelReservation"), UIControlEvent.TouchUpInside); this.View.AddSubview (btn); }
public override void ViewDidLoad() { base.ViewDidLoad(); var token = UIDevice.CurrentDevice.Name; try { // 调试按钮 _debugButton = CreateButtonToView(View, "...", NSLayoutAttribute.CenterX, NSLayoutAttribute.Top); } catch (Exception ex) { } try { // Token 按钮 _tokenButton = CreateButtonToView(View, $"使用此文本设置你的 PC 键盘:{token}", NSLayoutAttribute.CenterX, NSLayoutAttribute.CenterY); } catch (Exception ex) { Debug(ex); } try { // 切换输入法按钮 _nextKeyboardButton = CreateButtonToView(View, "Next Keyboard", NSLayoutAttribute.Left, NSLayoutAttribute.Bottom); _nextKeyboardButton.AddTarget(this, new Selector("advanceToNextInputMode"), UIControlEvent.TouchUpInside); } catch (Exception ex) { Debug(ex); } try { // 确认按钮 _returnButton = CreateButtonToView(View, TextDocumentProxy.ReturnKeyType.ToString(), NSLayoutAttribute.Right, NSLayoutAttribute.Bottom); } catch (Exception ex) { Debug(ex); } // 初始化打字。 if (_receiver == null) { _receiver = new CloudKeyboardReceiver(HostInfo.BaseUrl, token); _receiver.Typing += DidReceive; _receiver.Confirmed += DidConfirm; _receiver.ExceptionOccurred += ExceptionDidOccur; } }
public override void ViewDidAppear(bool animated) { base.ViewDidAppear(animated); customizedTab = new CurvedBottomNavigationView(); element = Element as CurvedBottomTabbedPage; customizedTab.Frame = this.TabBar.Frame; customizedTab.Items = this.TabBar.Items; customizedTab.SelectedItem = this.TabBar.SelectedItem; customizedTab.TintColor = this.TabBar.TintColor; customizedTab.UnselectedItemTintColor = this.TabBar.UnselectedItemTintColor; customizedTab.BarBackgroundColor = this.TabBar.BarTintColor; customizedTab.BackgroundColor = Xamarin.Forms.Color.Transparent.ToUIColor(); customizedTab.ItemSpacing = 4f; customizedTab.ClipsToBounds = true; this.TabBar.RemoveFromSuperview(); SetMenuItems(); // Creates a Button var appButton = new UIButton(UIButtonType.Custom); UIImage imageAppButtonButton = UIImage.FromBundle(element.FabIcon); if (imageAppButtonButton != null) { appButton.SetImage(imageAppButtonButton, UIControlState.Normal); } // Sets width and height to the Button appButton.Frame = new CGRect(0.0f, 0.0f, 48, 48); //appButton.SetBackgroundImage(imageAppButtonButton, UIControlState.Normal); appButton.BackgroundColor = UIColor.FromCGColor(element.FabBackgroundColor.ToCGColor()); CGPoint centers = TabBar.Center; centers.Y = this.customizedTab.Frame.Y; appButton.Center = centers; var eventHandler = new EventHandler(ButtonClick); appButton.AddTarget(eventHandler, events: UIControlEvent.TouchUpInside); //Create shadow effect appButton.Layer.ShadowColor = UIColor.Black.CGColor; appButton.Layer.ShadowOffset = new CGSize(width: 0.0, height: 5.0); appButton.Layer.ShadowOpacity = 0.5f; appButton.Layer.ShadowRadius = 2.0f; appButton.Layer.MasksToBounds = false; appButton.Layer.CornerRadius = 24; // Adds the Button to the view View.Add(customizedTab); View.AddSubview(appButton); }
private UIView CreateOkCancelButtonsView(Action <bool> action, string okText = null, string cancelText = null) { var stack = new UIStackView() { Alignment = UIStackViewAlignment.Fill, AutoresizingMask = UIViewAutoresizing.All, Distribution = UIStackViewDistribution.Fill, Axis = UILayoutConstraintAxis.Horizontal }; stack.HeightAnchor.ConstraintEqualTo(ButtonRowHeight).Active = true; var okButton = new UIButton { BackgroundColor = UIColor.Clear }; okButton.SetTitle(okText ?? "OK", UIControlState.Normal); okButton.SetTitleColor(ButtonTextUiColor, UIControlState.Normal); okButton.AddTarget((x, y) => { try { action(true); } catch (Exception e) { Console.WriteLine(e); } finally { DismissController(); } }, UIControlEvent.TouchUpInside); okButton.WidthAnchor.ConstraintEqualTo(TopController.View.Frame.Width / 2 - 1).Active = true; //var separator = new UIView {BackgroundColor = SeparatorColor}; //separator.WidthAnchor.ConstraintEqualTo(1).Active = true; var cancelButton = new UIButton { BackgroundColor = UIColor.Clear }; cancelButton.SetTitle((string.IsNullOrEmpty(cancelText) ? "Cancel" : cancelText), UIControlState.Normal); cancelButton.SetTitleColor(ButtonTextUiColor, UIControlState.Normal); cancelButton.AddTarget((x, y) => { DismissController(); }, UIControlEvent.TouchUpInside); okButton.WidthAnchor.ConstraintEqualTo(TopController.View.Frame.Width / 2).Active = true; stack.AddArrangedSubview(okButton); //stack.AddArrangedSubview(separator); stack.AddArrangedSubview(cancelButton); return(stack); }
private void SetupControls() { _labelTitle.TranslatesAutoresizingMaskIntoConstraints = false; _buttonPrev.TranslatesAutoresizingMaskIntoConstraints = false; _buttonPrev.AddTarget(OnPrevClicked, UIControlEvent.TouchUpInside); _buttonNext.TranslatesAutoresizingMaskIntoConstraints = false; _buttonNext.AddTarget(OnNextClicked, UIControlEvent.TouchUpInside); }
private void makeButton() { // A button to test removing the heatmap. button = new UIButton(frame: new CGRect(x: 5, y: 150, width: 200, height: 35)); button.BackgroundColor = UIColor.Blue; button.Alpha = 0.5f; button.SetTitle("Remove heatmap", forState: UIControlState.Normal); button.AddTarget(this, sel: new ObjCRuntime.Selector("removeHeatmap"), UIControlEvent.TouchUpInside); this.mapView.AddSubview(button); }
private void SetupUI() { ScrollView = new UIScrollView() { BackgroundColor = UIColor.FromPatternImage(Images.TableViewBackground), Frame = new RectangleF(0, 0, View.Bounds.Width, View.Bounds.Height), PagingEnabled = false, ScrollEnabled = true }; View.Add(ScrollView); TopBarArea = new UITextField() { BackgroundColor = UIColor.White, Enabled = false, Font = FontConstants.SourceSansProRegular(13), Frame = new RectangleF(14f, 22f, 294f, 32f), LeftView = new UIImageView(Images.TimeIcon), LeftViewMode = UITextFieldViewMode.Always, Text = Prayer.Timestamp.ToShortDateString(), TextAlignment = UITextAlignment.Left, VerticalAlignment = UIControlContentVerticalAlignment.Center }; ContentArea = new UILabel() { BackgroundColor = UIColor.White, Font = FontConstants.SourceSansProRegular(13), Frame = new RectangleF(14f, 48f, 294f, 10f), LineBreakMode = UILineBreakMode.TailTruncation, Lines = 0, Text = Prayer.Content, TextAlignment = UITextAlignment.Left }; ScrollView.Add(ContentArea); ContentArea.Frame = new RectangleF(14f, 52f, 294f, InterfaceHelper.ContentSize(ContentArea.Text, ContentArea.Frame.Width, ContentArea.Font)); var height = ContentArea.Bounds.Height + 79f; ShareButton = new UIButton() { Frame = new RectangleF(33.5f, height, 253f, 33f) }; ShareButton.SetBackgroundImage(Images.ShareButton, UIControlState.Normal); ShareButton.AddTarget(HandleShareTapped, UIControlEvent.TouchUpInside); ScrollView.Add(TopBarArea); ScrollView.Add(ShareButton); // ShareButton + NavBar + TabBar + (2 * 22f) var contentSize = ShareButton.Frame.Y + 170; ScrollView.ContentSize = new SizeF(320f, contentSize); }
public void LoadButtons() { pauseButton = new UIButton(UIButtonType.RoundedRect); pauseButton.Frame = new CGRect(78,291,180,40); pauseButton.SetTitle("Pause",UIControlState.Normal); resumeButton = new UIButton(UIButtonType.RoundedRect); resumeButton.Frame = new CGRect(78,346,180,40); resumeButton.SetTitle("Resume",UIControlState.Normal); pauseButton.AddTarget(ClickedPause,UIControlEvent.TouchUpInside); resumeButton.AddTarget(ClickedResume,UIControlEvent.TouchUpInside); View.AddSubview(pauseButton); View.AddSubview(resumeButton); }
public override void ViewDidLoad() { base.ViewDidLoad (); UIButton button = new UIButton (UIButtonType.System); button.SetTitle ("Tap to load iOS 7 style calendar", UIControlState.Normal); button.AddTarget (this, new Selector ("ButtonTouched"), UIControlEvent.TouchUpInside); button.Frame = new CGRect (0, this.View.Bounds.Size.Height / 2f - 20f, this.View.Bounds.Size.Width, 40f); button.AutoresizingMask = UIViewAutoresizing.FlexibleBottomMargin | UIViewAutoresizing.FlexibleTopMargin | UIViewAutoresizing.FlexibleLeftMargin | UIViewAutoresizing.FlexibleRightMargin; this.View.AddSubview (button); }
public void CreateButton(string title, NSObject target, Selector selector, CGPoint origin) { NSString titleString = new NSString (title); UIStringAttributes attributes = new UIStringAttributes () { Font = UIFont.SystemFontOfSize (18) }; CGSize titleSize = titleString.GetSizeUsingAttributes(attributes); UIButton button = new UIButton (new CGRect (origin.X, origin.Y, titleSize.Width, 44)); button.TitleLabel.Font = UIFont.SystemFontOfSize (14); button.Layer.BorderWidth = 1.0f; button.Layer.BorderColor = UIColor.White.CGColor; button.Layer.CornerRadius = 3.0f; button.SetTitle (title, UIControlState.Normal); button.SetTitleColor (UIColor.White, UIControlState.Normal); button.AddTarget (target, selector, UIControlEvent.TouchUpInside); this.SideDrawerView.MainView.AddSubview (button); }
public static UIButton Button(UIView View, String Title, Object Target, EventHandler handler) { UIButton btn = new UIButton (UIButtonType.Custom); btn.BackgroundColor = new UIColor (0.5f, 0.7f, 0.2f, 1f); btn.SetTitleColor (new UIColor (1f, 1f, 1f, 1f), UIControlState.Normal); btn.SetTitle (Title, UIControlState.Normal); btn.TitleLabel.Font = UIFont.SystemFontOfSize (12); btn.Layer.CornerRadius = 40; btn.ClipsToBounds = true; btn.Frame = new CGRect ((View.Frame.Size.Width - 80)/2, View.Frame.Size.Height - 180, 80, 80); btn.AutoresizingMask = UIViewAutoresizing.FlexibleRightMargin | UIViewAutoresizing.FlexibleTopMargin | UIViewAutoresizing.FlexibleLeftMargin; btn.AddTarget(handler, UIControlEvent.TouchUpInside); View.AddSubview (btn); return btn; }
public void CreateButton(string title, NSObject target, Selector selector) { NSString titleString = new NSString (title); UIStringAttributes attributes = new UIStringAttributes () { Font = UIFont.SystemFontOfSize (18) }; CGSize titleSize = titleString.GetSizeUsingAttributes(attributes); UIButton button = new UIButton (new CGRect (15, 15 + buttonY, titleSize.Width, 44)); button.TitleLabel.Font = UIFont.SystemFontOfSize (14); button.Layer.BorderWidth = 1.0f; button.Layer.BorderColor = UIColor.White.CGColor; button.Layer.CornerRadius = 3.0f; button.SetTitle (title, UIControlState.Normal); button.SetTitleColor (UIColor.White, UIControlState.Normal); button.AddTarget (target, selector, UIControlEvent.TouchUpInside); scrollView.AddSubview (button); buttonY += 50; scrollView.ContentSize = new CGSize (Math.Max (button.Frame.Width, scrollView.ContentSize.Width), buttonY + 15 + this.View.Bounds.Y); }
public NotificationBar (NSCoder coder) : base (coder) { heightConstraint = NSLayoutConstraint.Create (this, Height, Equal, null, NoAttribute, 1, 0); TranslatesAutoresizingMaskIntoConstraints = false; BackgroundColor = UIColor.Black; AddConstraint (heightConstraint); label = new UILabel { Text = "You have a new CloudKit notification!", TextColor = UIColor.White, TextAlignment = UITextAlignment.Center, TranslatesAutoresizingMaskIntoConstraints = false, Hidden = true, UserInteractionEnabled = true }; AddSubview (label); button = new UIButton (); button.SetTitle ("✕", UIControlState.Normal); button.AddTarget (Close, UIControlEvent.TouchDown); button.TranslatesAutoresizingMaskIntoConstraints = false; button.Hidden = true; AddSubview (button); var rightConstraint = NSLayoutConstraint.Create (this, RightMargin, Equal, button, Right, 1, 0); AddConstraint (rightConstraint); var centerConstraint = NSLayoutConstraint.Create (this, CenterY, Equal, button, CenterY, 1, 0); AddConstraint (centerConstraint); var leftConstraint = NSLayoutConstraint.Create (this, LeftMargin, Equal, label, Left, 1, 0); AddConstraint (leftConstraint); var rightLabelConstraint = NSLayoutConstraint.Create (button, Left, Equal, label, Right, 1, 8); AddConstraint (rightLabelConstraint); var centerLabelConstraint = NSLayoutConstraint.Create (this, CenterY, Equal, label, CenterY, 1, 0); AddConstraint (centerLabelConstraint); var tapGestureRecognizer = new UITapGestureRecognizer (ShowNotification); label.AddGestureRecognizer (tapGestureRecognizer); }
private void SetupMainButton () { mainButton = new UIButton (UIButtonType.System); mainButton.TitleLabel.Font = UIFont.SystemFontOfSize (80); mainButton.SetTitle (SingleWord, UIControlState.Normal); mainButton.SizeToFit (); mainButton.TranslatesAutoresizingMaskIntoConstraints = false; mainButton.AddTarget (this, new Selector ("PrintWord"), UIControlEvent.TouchUpInside); View.AddSubview (mainButton); var mainButtonCenterXSideConstraint = NSLayoutConstraint.Create (mainButton, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, View, NSLayoutAttribute.CenterX, 1.0f, 0.0f); var mainButtonCenterYsConstraint = NSLayoutConstraint.Create (mainButton, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, View, NSLayoutAttribute.CenterY, 1.0f, 0.0f); View.AddConstraints (new [] { mainButtonCenterXSideConstraint, mainButtonCenterYsConstraint }); }
public override void ViewDidLoad() { base.ViewDidLoad (); // Perform custom UI setup here nextKeyboardButton = new UIButton (UIButtonType.System); nextKeyboardButton.SetTitle ("Next Keyboard", UIControlState.Normal); nextKeyboardButton.SizeToFit (); nextKeyboardButton.TranslatesAutoresizingMaskIntoConstraints = false; nextKeyboardButton.AddTarget (this, new Selector ("advanceToNextInputMode"), UIControlEvent.TouchUpInside); View.AddSubview (nextKeyboardButton); var nextKeyboardButtonLeftSideConstraint = NSLayoutConstraint.Create (nextKeyboardButton, NSLayoutAttribute.Left, NSLayoutRelation.Equal, View, NSLayoutAttribute.Left, 1.0f, 0.0f); var nextKeyboardButtonBottomConstraint = NSLayoutConstraint.Create (nextKeyboardButton, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, View, NSLayoutAttribute.Bottom, 1.0f, 0.0f); View.AddConstraints (new [] { nextKeyboardButtonLeftSideConstraint, nextKeyboardButtonBottomConstraint }); }
public override void ViewDidLoad() { base.ViewDidLoad (); //scrollView = stackView.Superview as UIScrollView; //scrollView.KeyboardDismissMode = UIScrollViewKeyboardDismissMode.OnDrag; //scrollView.ScrollEnabled = true; // Set up Navigation Bar var saveButton = new UIBarButtonItem (UIBarButtonSystemItem.Save, save); var cancelButton = new UIBarButtonItem (UIBarButtonSystemItem.Cancel, cancel); NavigationItem.Title = "New Medication:"; NavigationItem.RightBarButtonItem = saveButton; NavigationItem.HidesBackButton = true; NavigationItem.LeftBarButtonItem = cancelButton; //NSNotificationCenter.DefaultCenter.AddObserver (this, new ObjCRuntime.Selector("keyboardDidAppear:"), UIKeyboard.DidShowNotification, null); //NSNotificationCenter.DefaultCenter.AddObserver (this, new ObjCRuntime.Selector ("keyboardWillDissapear:"), UIKeyboard.WillHideNotification, null); // Set up the date formatter dateFormat = new NSDateFormatter(); dateFormat.DateStyle = NSDateFormatterStyle.None; dateFormat.TimeStyle = NSDateFormatterStyle.Short; // Set up new pet form nameField = new UITextField(); nameField.Text = "Medication Name"; nameField.BorderStyle = UITextBorderStyle.RoundedRect; nameField.ReturnKeyType = UIReturnKeyType.Done; medTypeLabel = new UILabel (); medTypeLabel.Text = "Type of Medication"; medTypeButton = new UIButton (UIButtonType.RoundedRect); medTypeButton.AddTarget (editMedType, UIControlEvent.TouchUpInside); medTypeButton.SetTitle ("Pill", UIControlState.Normal); medTypeButton.TitleLabel.Font = medTypeButton.TitleLabel.Font.WithSize (medTypeLabel.Font.PointSize); medTypePicker = new UIPickerView (); medTypePicker.Delegate = new MedTypePickerDelegate (this); medTypePicker.DataSource = new MedTypePickerDataSource (); freqLabel = new UILabel (); freqLabel.Text = "Frequency"; freqTextField = new UITextField (); freqTextField.Text = "1"; freqTextField.KeyboardType = UIKeyboardType.NumberPad; freqTextField.BorderStyle = UITextBorderStyle.RoundedRect; freqTextField.Enabled = false; freqTextField.AddTarget (freqTextFieldChanged, UIControlEvent.EditingDidEnd | UIControlEvent.EditingDidEndOnExit); freqStepper = new UIStepper (); freqStepper.Value = 1; freqStepper.MinimumValue = 1; freqStepper.Enabled = false; freqStepper.AddTarget (freqStepperIncremented, UIControlEvent.ValueChanged); UIStackView freqStackView = new UIStackView (new UIView[] { freqTextField, freqStepper }); freqStackView.Spacing = 8; freqStackView.Axis = UILayoutConstraintAxis.Horizontal; freqButton = new UIButton (UIButtonType.RoundedRect); freqButton.SetTitle ("Daily", UIControlState.Normal); freqButton.TitleLabel.Font = freqButton.TitleLabel.Font.WithSize (medTypeLabel.Font.PointSize); freqButton.AddTarget (editFrequency, UIControlEvent.TouchUpInside); freqPicker = new UIPickerView (); freqPicker.Delegate = new MedFreqPickerDelegate (this); freqPicker.DataSource = new MedFreqPickerDataSource (); timePicker = new UIDatePicker (); gregorian = new NSCalendar (NSCalendarType.Gregorian); timePicker.Date = gregorian.DateBySettingsHour (9, 0, 0, NSDate.Now, NSCalendarOptions.MatchNextTime); timePicker.Mode = UIDatePickerMode.Time; timePicker.AddTarget (timePickerChanged, UIControlEvent.AllEvents); UILabel timeLabel = new UILabel (); timeLabel.Text = "Time"; timeButtons = new UIButton[1]; timeDates = new NSDate[1]; timeDates [0] = gregorian.DateBySettingsHour (9, 0, 0, NSDate.Now, NSCalendarOptions.MatchNextTime); timeButtons [0] = new UIButton (UIButtonType.RoundedRect); timeButtons [0].SetTitle ("9:00 AM", UIControlState.Normal); timeButtons [0].AddTarget (openTimePicker, UIControlEvent.TouchUpInside); timeStack = new UIStackView (); timeStack.Alignment = UIStackViewAlignment.Leading; timeStack.Distribution = UIStackViewDistribution.FillProportionally; timeStack.Spacing = 5; timeStack.Axis = UILayoutConstraintAxis.Vertical; timeStack.AddArrangedSubview (timeLabel); foreach (var button in timeButtons) { timeStack.AddArrangedSubview (button); } timeStack.AddArrangedSubview (timePicker); timePicker.Hidden = true; dayLabel = new UILabel (); dayLabel.Text = "Day"; dayLabel.Hidden = true; dayButton = new UIButton (UIButtonType.RoundedRect); var day = gregorian.GetComponentFromDate (NSCalendarUnit.Weekday, NSDate.Now); dayButton.SetTitle (gregorian.WeekdaySymbols[day], UIControlState.Normal); dayButton.AddTarget (openDayPicker, UIControlEvent.TouchUpInside); dayButton.Hidden = true; dayPicker = new UIDatePicker (); dayPicker.Mode = UIDatePickerMode.Date; dayPicker.MinimumDate = NSDate.Now; dayPicker.MaximumDate = NSDate.Now.AddSeconds (604800); dayPicker.AddTarget (dayPickerChanged, UIControlEvent.AllEvents); dayPicker.Hidden = true; prescriptionLengthLabel = new UILabel (); prescriptionLengthLabel.Text = "Prescription Length"; prescriptionLengthTextField = new UITextField (); prescriptionLengthTextField.Text = "20"; prescriptionLengthTextField.AddTarget (prescriptionTextFieldChanged, UIControlEvent.EditingDidEnd | UIControlEvent.EditingDidEndOnExit); prescriptionLengthTextField.KeyboardType = UIKeyboardType.NumberPad; prescriptionLengthTextField.BorderStyle = UITextBorderStyle.RoundedRect; prescriptionLengthStepper = new UIStepper (); prescriptionLengthStepper.Value = 20; prescriptionLengthStepper.MinimumValue = 1; prescriptionLengthStepper.AddTarget (prescriptionStepperIncremented, UIControlEvent.ValueChanged); prescriptionDayLabel = new UILabel (); prescriptionDayLabel.Text = "Days"; UIStackView prescriptionStackView = new UIStackView (new UIView[] { prescriptionLengthTextField, prescriptionLengthStepper, prescriptionDayLabel }); prescriptionStackView.Axis = UILayoutConstraintAxis.Horizontal; prescriptionStackView.Alignment = UIStackViewAlignment.Leading; prescriptionStackView.Distribution = UIStackViewDistribution.FillProportionally; prescriptionStackView.Spacing = 5; refillsLabel = new UILabel (); refillsLabel.Text = "Refills Remaining"; refillsTextField = new UITextField (); refillsTextField.Text = "0"; refillsTextField.KeyboardType = UIKeyboardType.NumberPad; refillsTextField.BorderStyle = UITextBorderStyle.RoundedRect; refillsTextField.AddTarget (refillsTextFieldChanged, UIControlEvent.EditingDidEnd | UIControlEvent.EditingDidEndOnExit); refillsStepper = new UIStepper (); refillsStepper.Value = 0; refillsStepper.MinimumValue = 0; refillsStepper.AddTarget (refillsStepperIncremented, UIControlEvent.ValueChanged); UIStackView refillsStackView = new UIStackView (new UIView[] { refillsTextField, refillsStepper }); refillsStackView.Spacing = 5; refillsStackView.Alignment = UIStackViewAlignment.Leading; refillsStackView.Distribution = UIStackViewDistribution.FillProportionally; refillsStackView.Axis = UILayoutConstraintAxis.Horizontal; pharmacyTextView = new UITextView (); pharmacyTextView.Text = "Pharmacy Address"; pharmacyTextView.ScrollEnabled = false; pharmacyTextView.BackgroundColor = UIColor.LightGray; pharmacyTextField = new UITextField (); pharmacyTextField.Text = "Pharmacy Address"; pharmacyTextField.BorderStyle = UITextBorderStyle.RoundedRect; // Sets up the stackview stackView.Spacing = 5; stackView.Alignment = UIStackViewAlignment.Leading; stackView.Distribution = UIStackViewDistribution.EqualSpacing; stackView.AddArrangedSubview (nameField); UIView spaceView = new UIView (CoreGraphics.CGRect.FromLTRB (0, 0, 50, SECTION_SPACER)); spaceView.AddConstraint (NSLayoutConstraint.Create (spaceView, NSLayoutAttribute.Height, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1, SECTION_SPACER)); stackView.AddArrangedSubview (spaceView); stackView.AddArrangedSubview (medTypeLabel); stackView.AddArrangedSubview (medTypeButton); stackView.AddArrangedSubview (medTypePicker); medTypePicker.Hidden = true; UIView spaceView2 = new UIView (CoreGraphics.CGRect.FromLTRB (0, 0, 50, SECTION_SPACER)); spaceView2.AddConstraint (NSLayoutConstraint.Create (spaceView2, NSLayoutAttribute.Height, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1, SECTION_SPACER)); stackView.AddArrangedSubview (spaceView2); stackView.AddArrangedSubview (freqLabel); stackView.AddArrangedSubview (freqStackView); stackView.AddArrangedSubview (freqButton); stackView.AddArrangedSubview (freqPicker); freqPicker.Hidden = true; UIView spaceView3 = new UIView (CoreGraphics.CGRect.FromLTRB (0, 0, 50, SECTION_SPACER)); spaceView3.AddConstraint (NSLayoutConstraint.Create (spaceView3, NSLayoutAttribute.Height, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1, SECTION_SPACER)); stackView.AddArrangedSubview (spaceView3); stackView.AddArrangedSubview (timeStack); stackView.AddArrangedSubview (dayLabel); stackView.AddArrangedSubview (dayButton); stackView.AddArrangedSubview (dayPicker); UIView spaceView4 = new UIView (CoreGraphics.CGRect.FromLTRB (0, 0, 50, SECTION_SPACER)); spaceView4.AddConstraint (NSLayoutConstraint.Create (spaceView4, NSLayoutAttribute.Height, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1, SECTION_SPACER)); stackView.AddArrangedSubview (spaceView4); stackView.AddArrangedSubview (prescriptionLengthLabel); stackView.AddArrangedSubview (prescriptionStackView); UIView spaceView5 = new UIView (CoreGraphics.CGRect.FromLTRB (0, 0, 50, SECTION_SPACER)); spaceView5.AddConstraint (NSLayoutConstraint.Create (spaceView5, NSLayoutAttribute.Height, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1, SECTION_SPACER)); stackView.AddArrangedSubview (spaceView5); stackView.AddArrangedSubview (refillsLabel); stackView.AddArrangedSubview (refillsStackView); UIView spaceView6 = new UIView (CoreGraphics.CGRect.FromLTRB (0, 0, 50, SECTION_SPACER)); spaceView6.AddConstraint (NSLayoutConstraint.Create (spaceView6, NSLayoutAttribute.Height, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1, SECTION_SPACER)); stackView.AddArrangedSubview (spaceView6); stackView.AddArrangedSubview (pharmacyTextField); UIView spaceView7 = new UIView (CoreGraphics.CGRect.FromLTRB (0, 0, 50, SECTION_SPACER)); spaceView7.AddConstraint (NSLayoutConstraint.Create (spaceView7, NSLayoutAttribute.Height, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1, SECTION_SPACER)); stackView.AddArrangedSubview (spaceView7); }
private void Prep() { AutosizesSubviews = !true; editing = false; UIButton delButton = new UIButton(UIButtonType.Custom); deleteButton = delButton; deleteButton.SetTitleColor(UIColor.Black,UIControlState.Normal); DeleteButtonIcon = null; DeleteButtonOffset=new PointF(-5,-5); deleteButton.Alpha = 0.0f; AddSubview(deleteButton); deleteButton.AddTarget(this,new Selector("actionDelete"),UIControlEvent.TouchUpInside); }
protected override void PrepareDialogViewController(UIViewController dvc) { base.PrepareDialogViewController (dvc); NavigationBarLabel = InterfaceHelper.LabelForTitle (Caption.ToUpper()); dvc.NavigationItem.TitleView = NavigationBarLabel; var backButton = new UIButton (new RectangleF (0, 0, 25, 25)); backButton.SetBackgroundImage (UIImage.FromFile ("Images/General/BackButton.png"), UIControlState.Normal); backButton.SetBackgroundImage (UIImage.FromFile ("Images/General/BackButtonHighlighted.png"), UIControlState.Highlighted); backButton.AddTarget((object sender, EventArgs args) => GoBack(dvc), UIControlEvent.TouchUpInside); BackButton = new UIBarButtonItem (backButton); dvc.NavigationItem.LeftBarButtonItem = BackButton; }
public async override void ViewDidLoad () { base.ViewDidLoad (); this.dataSource = new TKDataSource (); await this.LoadTodo (); var bounds = this.View.Bounds; bounds.Height -= this.NavigationController.NavigationBar.Bounds.Height; bounds.Height -= UIApplication.SharedApplication.StatusBarFrame.Height; bounds.Y += this.NavigationController.NavigationBar.Bounds.Height; bounds.Y += UIApplication.SharedApplication.StatusBarFrame.Height; this.listView.Frame = bounds; this.listView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight; this.listView.WeakDataSource = this.dataSource; this.listView.AllowsCellSwipe = true; this.listView.CellSwipeLimits = new UIEdgeInsets (0, 60, 0, 60); this.listView.CellSwipeTreshold = 30; this.listView.Delegate = new ListViewDelegate (this); this.dataSource.Settings.ListView.CreateCell(delegate (TKListView listView, NSIndexPath indexPath, NSObject item) { TKListViewCell cell = listView.DequeueReusableCell("defaultCell", indexPath) as TKListViewCell; if (cell.SwipeBackgroundView.Subviews.Length == 0) { var size = cell.Frame.Size; var rDelete = new UIButton (new CGRect (size.Width - 60, 0, 60, size.Height)); rDelete.SetTitle ("Delete", UIControlState.Normal); rDelete.BackgroundColor = UIColor.Red; rDelete.AddTarget(DeleteButton, UIControlEvent.TouchUpInside); cell.SwipeBackgroundView.AddSubview (rDelete); var lDelete = new UIButton (new CGRect (0, 0, 60, size.Height)); lDelete.SetTitle ("Delete", UIControlState.Normal); lDelete.BackgroundColor = UIColor.Red; lDelete.AddTarget(DeleteButton, UIControlEvent.TouchUpInside); cell.SwipeBackgroundView.AddSubview (lDelete); } return cell; }); this.dataSource.Settings.ListView.InitCell (delegate (TKListView listView, NSIndexPath indexPath, TKListViewCell cell, NSObject item) { var dict = (NSMutableDictionary)item; cell.TextLabel.Text = (NSString) dict.ValueForKey(new NSString("title")); // todoItem.Title; cell.DetailTextLabel.Text = (NSString) dict.ValueForKey(new NSString("content")); cell.ContentInsets = new UIEdgeInsets(1,10,1,10); }); var addItem = new UIBarButtonItem("Action", UIBarButtonItemStyle.Plain, (s, e) => { UIAlertController actionSheetAlert = UIAlertController.Create("Actions", "Select an action", UIAlertControllerStyle.ActionSheet); // Add Actions actionSheetAlert.AddAction(UIAlertAction.Create("Add Todo", UIAlertActionStyle.Default, (action) => { var dataForm = new TodoDataEntry(); this.NavigationController.PushViewController(dataForm, true); })); actionSheetAlert.AddAction(UIAlertAction.Create("Logout",UIAlertActionStyle.Default, (UIAlertAction obj) => { Globals.theSettings = null; Globals.SQLite.Execute("DELETE FROM Settings"); var appDelegate = UIApplication.SharedApplication.Delegate as AppDelegate; appDelegate.navigationController.PopToRootViewController(true); appDelegate.navigationController.ViewControllers = new List<UIViewController> { new LoginView() }.ToArray(); })); actionSheetAlert.AddAction(UIAlertAction.Create("Cancel", UIAlertActionStyle.Cancel, (action) => Application.Debug ("Cancel button pressed."))); // Required for iPad - You must specify a source for the Action Sheet since it is // displayed as a popover UIPopoverPresentationController presentationPopover = actionSheetAlert.PopoverPresentationController; if (presentationPopover != null) { presentationPopover.SourceView = this.View; presentationPopover.PermittedArrowDirections = UIPopoverArrowDirection.Up; } // Display the alert this.PresentViewController(actionSheetAlert,true,null); } ); this.NavigationItem.SetRightBarButtonItems(new UIBarButtonItem[] { addItem }, true); this.View.AddSubview (this.listView); }
public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath ) { // get cell to reuse or create new one. UITableViewCell cell; if (rssType == ListViewControllerRSSType.BNRFeed) { cell = tableView.DequeueReusableCell("UITableViewCellBNR"); if (cell == null) { cell = new UITableViewCell(UITableViewCellStyle.Subtitle, "UITableViewCellBNR"); } } else { cell = tableView.DequeueReusableCell("UITableViewCellApple"); if (cell == null) { cell = new UITableViewCell(UITableViewCellStyle.Subtitle, "UITableViewCellApple"); } } // Get item and initialize cell with item info RSSItem item = BNRFeedStore.items[indexPath.Row]; cell.TextLabel.Text = item.title; cell.TextLabel.TextColor = UIColor.Yellow; cell.DetailTextLabel.Text = item.subForum; cell.DetailTextLabel.TextColor = UIColor.Yellow; cell.UserInteractionEnabled = true; cell.BackgroundColor = UIColor.Clear; cell.Accessory = UITableViewCellAccessory.None; cell.SelectedBackgroundView = new UIView(){ Frame = cell.Frame, BackgroundColor = UIColor.FromRGB(0.3f, 0.3f, 0.3f) }; // For BNRFeed list. set up Favbutton, check if favorite, decorate button accordingly, add to cell view if (rssType == ListViewControllerRSSType.BNRFeed) { UIButton favButton = new UIButton(UIButtonType.RoundedRect); favButton.Frame = new CGRect(cell.Frame.Size.Width-17, 0, 17, 44); favButton.AddTarget(this, new Selector("favButtonPressed:"), UIControlEvent.TouchUpInside); favButton.SetTitle("F", UIControlState.Normal); favButton.SetTitleColor(UIColor.White, UIControlState.Normal); favButton.BackgroundColor = UIColor.FromRGB(0.3f, 0.3f, 0.3f); favButton.Tag = indexPath.Row; favButton.AutoresizingMask = UIViewAutoresizing.FlexibleLeftMargin; cell.BringSubviewToFront(favButton); if (item.isFavorite) { favButton.SetTitleColor(UIColor.Green, UIControlState.Normal); favButton.BackgroundColor = UIColor.FromRGB(0.4f, 0.4f, 0.4f); } cell.AddSubview(favButton); } // Set checkmark for read items. if (item.isRead) cell.Accessory = UITableViewCellAccessory.Checkmark; return cell; }
public override void ViewDidLoad() { base.ViewDidLoad (); buttonAnimationEnabled = true; NSMutableDictionary mails = new NSMutableDictionary (); mails.Add (new NSString("Joyce Dean"), new NSString("Sales report for January")); mails.Add (new NSString("Joel Robertson"), new NSString("Planned network mainternance")); mails.Add (new NSString("Sherman Martin"), new NSString("IT help desk")); mails.Add (new NSString("Lela Richardson"), new NSString("Summaries of my interviews with customers")); mails.Add (new NSString("Jackie Maldonado"), new NSString("REMAINDER: corporate meeting")); mails.Add (new NSString("Kathryn Byrd"), new NSString("Stock options")); mails.Add (new NSString("Ervin Powers"), new NSString("Thank you!")); mails.Add (new NSString("Leland Warner"), new NSString("Meeting with Jack")); mails.Add (new NSString("Nicholas Bowers"), new NSString("Please share these articles")); mails.Add (new NSString("Alex Soto"), new NSString("Additional information for Jack")); mails.Add (new NSString("Naomi Carson"), new NSString("Miss you!")); mails.Add (new NSString("Lela Richardson"), new NSString("Summaries of my interviews with customers")); mails.Add (new NSString("Rufus Edwards"), new NSString("Training")); mails.Add (new NSString("Kathryn Byrd"), new NSString("Stock options")); mails.Add (new NSString("Ian Ellis"), new NSString("Do you like this blog article?")); mails.Add (new NSString("Pat Vasquez"), new NSString("The latest UI design")); mails.Add (new NSString("Chelsea Burton"), new NSString("Need this article!")); mails.Add (new NSString("Karl Bates"), new NSString("Training update")); mails.Add (new NSString("Evan Rivera"), new NSString("Safety instructions")); mails.Add (new NSString("Tony Lawson"), new NSString("Missed our converstation")); mails.Add (new NSString("Wallace Little"), new NSString("Swift is awessome")); mails.Add (new NSString("Carrie Tran"), new NSString("Missed conference call with Jack")); mails.Add (new NSString("Tyler Washington"), new NSString("HR question")); mails.Add (new NSString("Dominick Holloway"), new NSString("Wellcome!")); mails.Add (new NSString("Clark Sharp"), new NSString("Important question!")); this.dataSource.ItemSource = mails; this.dataSource.Settings.ListView.CreateCell(delegate (TKListView listView, NSIndexPath indexPath, NSObject item) { TKListViewCell cell = listView.DequeueReusableCell("defaultCell", indexPath) as TKListViewCell; if (cell.SwipeBackgroundView.Subviews.Length == 0) { CGSize size = cell.Frame.Size; UIFont font = UIFont.SystemFontOfSize(14); UIButton bMore = new UIButton(new CGRect(size.Width - 180, 0, 60, size.Height)); bMore.SetTitle("More", UIControlState.Normal); bMore.BackgroundColor = UIColor.LightGray; bMore.TitleLabel.Font = font; bMore.AddTarget(ButtonTouched, UIControlEvent.TouchUpInside); cell.SwipeBackgroundView.AddSubview(bMore); UIButton bFlag = new UIButton(new CGRect(size.Width - 120, 0, 60, size.Height)); bFlag.SetTitle("Flag", UIControlState.Normal); bFlag.BackgroundColor = UIColor.Orange; bFlag.TitleLabel.Font = font; bFlag.AddTarget(ButtonTouched, UIControlEvent.TouchUpInside); cell.SwipeBackgroundView.AddSubview(bFlag); UIButton bTrash = new UIButton(new CGRect(size.Width - 60, 0, 60, size.Height)); bTrash.SetTitle("Trash", UIControlState.Normal); bTrash.BackgroundColor = UIColor.Red; bTrash.TitleLabel.Font = font; bTrash.AddTarget(ButtonTouched, UIControlEvent.TouchUpInside); cell.SwipeBackgroundView.AddSubview(bTrash); UIButton bUnread = new UIButton(new CGRect(0, 0, 60, size.Height)); bUnread.SetTitle("Mark as Unread", UIControlState.Normal); bUnread.BackgroundColor = UIColor.Blue; bUnread.TitleLabel.Font = font; bUnread.TitleLabel.LineBreakMode = UILineBreakMode.WordWrap; bUnread.TitleLabel.TextAlignment = UITextAlignment.Center; bUnread.AddTarget(ButtonTouched, UIControlEvent.TouchUpInside); cell.SwipeBackgroundView.AddSubview(bUnread); } return cell; }); this.dataSource.Settings.ListView.InitCell (delegate (TKListView listView, NSIndexPath indexPath, TKListViewCell cell, NSObject item) { cell.TextLabel.Text = item as NSString; NSDictionary dict = this.dataSource.ItemSource as NSDictionary; cell.DetailTextLabel.AttributedText = this.AttributedMailText(dict[item] as NSString); cell.ContentInsets = new UIEdgeInsets(5,10,5,10); }); this.listView.Frame = this.View.Bounds; this.listView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight; this.listView.WeakDataSource = this.dataSource; this.listView.Delegate = new ListViewDelegate (this); this.listView.AllowsCellSwipe = true; this.listView.CellSwipeLimits = new UIEdgeInsets (0, 60, 0, 180); this.listView.CellSwipeTreshold = 30; this.View.AddSubview (this.listView); TKListViewLinearLayout layout = (TKListViewLinearLayout)this.listView.Layout; layout.ItemSize = new CGSize (100, 80); }
public override void TouchesEnded(NSSet touches, UIEvent evt) { if(string.IsNullOrEmpty(_disabled) && !_confirmed) { var point = (touches.AnyObject as UITouch).LocationInView(this.Superview); if(!Frame.Contains(point)) { Lighten(); base.TouchesCancelled(touches, evt); } else if(Selected) { Lighten(); _confirmed = true; _cancelOverlay.RemoveFromSuperview(); _cancelOverlay = null; base.TouchesEnded(touches, evt); } else { Lighten(); Selected = true; _cancelOverlay = UIButton.FromType(UIButtonType.Custom); _cancelOverlay.Frame = new RectangleF(0, 0, 1024, 1024); _cancelOverlay.AddTarget(delegate { Cancel(); }, UIControlEvent.TouchDown); Superview.AddSubview(_cancelOverlay); Superview.BringSubviewToFront(this); } } }
private void SetupNavigationBar() { var backButton = new UIButton (new RectangleF (0, 0, 25, 25)); backButton.SetBackgroundImage (UIImage.FromFile (Images.BackButton), UIControlState.Normal); backButton.SetBackgroundImage (UIImage.FromFile (Images.BackButtonHighlighted), UIControlState.Highlighted); backButton.AddTarget(HandleBackButtonTapped, UIControlEvent.TouchUpInside); backNavigationButton = new UIBarButtonItem (backButton); NavigationItem.LeftBarButtonItem = backNavigationButton; }
public override void ViewDidLoad() { base.ViewDidLoad (); var bounds = View.Bounds; var backgroundColor = new UIColor (0.859f, 0.866f, 0.929f, 1); View.BackgroundColor = backgroundColor; // // Add the bubble chat interface // discussionHost = new UIView (new RectangleF (bounds.X, bounds.Y, bounds.Width, bounds.Height-entryHeight)) { AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth, AutosizesSubviews = true, UserInteractionEnabled = true }; View.AddSubview (discussionHost); discussionHost.AddSubview (discussion.View); discussion.View.BackgroundColor = backgroundColor; // // Add styled entry // chatBar = new UIImageView (new RectangleF (0, bounds.Height-entryHeight, bounds.Width, entryHeight)) { ClearsContextBeforeDrawing = false, AutoresizingMask = UIViewAutoresizing.FlexibleTopMargin | UIViewAutoresizing.FlexibleWidth, Image = UIImage.FromFile ("ChatBar.png").StretchableImage (18, 20), UserInteractionEnabled = true }; View.AddSubview (chatBar); entry = new UITextView (new RectangleF (10, 9, 234, 22)) { ContentSize = new SizeF (234, 22), AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight, ScrollEnabled = false, ScrollIndicatorInsets = new UIEdgeInsets (5, 0, 4, -2), ClearsContextBeforeDrawing = false, Font = UIFont.SystemFontOfSize (messageFontSize), DataDetectorTypes = UIDataDetectorType.All, BackgroundColor = UIColor.Clear, }; // Fix a scrolling glitch entry.ShouldChangeText = (textView, range, text) => { entry.ContentInset = new UIEdgeInsets (0, 0, 3, 0); return true; }; previousContentHeight = entry.ContentSize.Height; chatBar.AddSubview (entry); // // The send button // sendButton = UIButton.FromType (UIButtonType.Custom); sendButton.ClearsContextBeforeDrawing = false; sendButton.Frame = new RectangleF (chatBar.Frame.Width - 70, 8, 64, 26); sendButton.AutoresizingMask = UIViewAutoresizing.FlexibleTopMargin | UIViewAutoresizing.FlexibleLeftMargin; var sendBackground = UIImage.FromFile ("SendButton.png"); sendButton.SetBackgroundImage (sendBackground, UIControlState.Normal); sendButton.SetBackgroundImage (sendBackground, UIControlState.Disabled); sendButton.TitleLabel.Font = UIFont.BoldSystemFontOfSize (16); sendButton.TitleLabel.ShadowOffset = new SizeF (0, -1); sendButton.SetTitle ("Send", UIControlState.Normal); sendButton.SetTitleShadowColor (new UIColor (0.325f, 0.463f, 0.675f, 1), UIControlState.Normal); sendButton.AddTarget (SendMessage, UIControlEvent.TouchUpInside); DisableSend (); chatBar.AddSubview (sendButton); // // Listen to keyboard notifications to animate // showObserver = UIKeyboard.Notifications.ObserveWillShow (PlaceKeyboard); hideObserver = UIKeyboard.Notifications.ObserveWillHide (PlaceKeyboard); ScrollToBottom (false); // Track changes in the entry to resize the view accordingly entry.Changed += HandleEntryChanged; }
void loadIPadLayout() { CGSize desiredSize = CGSize.Empty; this.offset = 0; if (sections.Count == 0 && options.Count == 1) { UIButton button = new UIButton (UIButtonType.RoundedRect); button.SetTitle (options [0].OptionText, UIControlState.Normal); button.AddTarget (optionTouched, UIControlEvent.TouchUpInside); desiredSize = button.SizeThatFits (this.View.Bounds.Size); button.Frame = new CGRect (30, 10 + this.headerHeight, desiredSize.Width, desiredSize.Height); this.View.AddSubview (button); this.offset = (float)(10 + desiredSize.Height + 10); } else if (options.Count >= 3 || sections.Count > 0) { settingsButton = new UIBarButtonItem (new UIImage ("menu.png"), UIBarButtonItemStyle.Plain, settingsTouched); this.NavigationItem.RightBarButtonItem = settingsButton; } else { UISegmentedControl segmented = new UISegmentedControl (); for (int i = 0; i < options.Count; i++) { segmented.InsertSegment (options [i].OptionText, i + 1, false); } desiredSize = segmented.SizeThatFits (this.View.Bounds.Size); segmented.Frame = new CGRect (10, 10 + this.headerHeight, desiredSize.Width, desiredSize.Height); segmented.AddTarget (optionTouched, UIControlEvent.ValueChanged); this.View.AddSubview (segmented); segmented.SelectedSegment = this.SelectedOption; this.offset = (float)(10 + desiredSize.Height + 10); } }
public ShortProfileView(RectangleF rect, long userId, bool discloseButton) : base(rect) { BackgroundColor = UIColor.Clear; user = User.FromId (userId); if (user == null){ Console.WriteLine ("userid={0}", userId); return; } // Pics are 73x73, but we will add a border. profilePic = new UIImageView (new RectangleF (10, 10, 73, 73)); profilePic.BackgroundColor = UIColor.Clear; profilePic.Image = ImageStore.RequestProfilePicture (-userId, user.PicUrl, this); AddSubview (profilePic); url = UIButton.FromType (UIButtonType.Custom); url.Font = urlFont; url.Font = urlFont; url.LineBreakMode = UILineBreakMode.TailTruncation; url.HorizontalAlignment = UIControlContentHorizontalAlignment.Left; url.TitleShadowOffset = new SizeF (0, 1); url.SetTitle (user.Url, UIControlState.Normal); url.SetTitle (user.Url, UIControlState.Highlighted); url.SetTitleColor (UIColor.FromRGB (0x32, 0x4f, 0x85), UIControlState.Normal); url.SetTitleColor (UIColor.Red, UIControlState.Highlighted); url.SetTitleShadowColor (UIColor.White, UIControlState.Normal); url.Frame = new RectangleF (TextX, 70, rect.Width-TextX, urlSize); url.AddTarget (delegate { if (UrlTapped != null) UrlTapped (); }, UIControlEvent.TouchUpInside); AddSubview (url); if (discloseButton){ var button = UIButton.FromType (UIButtonType.DetailDisclosure); button.Frame = new RectangleF (290, 36, 20, 20); AddSubview (button); button.TouchDown += delegate { Tapped (); }; } }
UIBarButtonItem CreateBarButton (NSString imageName, NSString selectedImageName, Selector selector) { var buttonImage = UIImage.FromFile (imageName.ToString ()); var button = new UIButton (new RectangleF (0, 0, (float)buttonImage.Size.Width, (float)buttonImage.Size.Height)); button.SetImage (buttonImage, UIControlState.Normal); button.SetImage (UIImage.FromFile (selectedImageName.ToString ()), UIControlState.Highlighted); button.AddTarget (this, selector, UIControlEvent.TouchUpInside); var barButton = new UIBarButtonItem (button); GunmetalTheme.Apply (barButton); return barButton; }
public override void LoadView() { base.LoadView (); View.BackgroundColor = UIColor.White; int spacing = GridViewConstants.IsIphone ? 10 : 15; GridView aGridView = new GridView(View.Bounds); aGridView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight; aGridView.BackgroundColor = UIColor.Clear; demoGridView = aGridView; View.AddSubview(demoGridView); demoGridView.Style = GridViewStyle.Swap; demoGridView.ItemSpacing = spacing; demoGridView.MinEdgeInsets = new UIEdgeInsets(spacing, spacing, spacing, spacing); demoGridView.CenterGrid = true; demoGridView.ActionDelegate = this; demoGridView.SortingDelegate = this; demoGridView.TransformDelegate = this; demoGridView.DataSource = this; UIButton infoButton = new UIButton(UIButtonType.InfoDark); infoButton.Frame = new RectangleF(View.Bounds.Size.Width - 40, View.Bounds.Size.Height - 40, 40, 40); infoButton.AutoresizingMask = UIViewAutoresizing.FlexibleLeftMargin | UIViewAutoresizing.FlexibleTopMargin; infoButton.AddTarget(this,new Selector("presentInfo"),UIControlEvent.TouchUpInside); View.AddSubview(infoButton); UISegmentedControl dataSegmentedControl = new UISegmentedControl(new String[]{"DataSet 1","DataSet 2"}); dataSegmentedControl.SizeToFit(); dataSegmentedControl.Frame = new RectangleF(5, View.Bounds.Size.Height - dataSegmentedControl.Bounds.Size.Height - 5, dataSegmentedControl.Bounds.Size.Width, dataSegmentedControl.Bounds.Size.Height); dataSegmentedControl.AutoresizingMask = UIViewAutoresizing.FlexibleRightMargin | UIViewAutoresizing.FlexibleTopMargin; dataSegmentedControl.TintColor = UIColor.Green; dataSegmentedControl.SelectedSegment = 0; dataSegmentedControl.AddTarget(this,new Selector("dataSetChange:"),UIControlEvent.ValueChanged); View.AddSubview(dataSegmentedControl); /* OptionsViewController *optionsController = [[OptionsViewController alloc] init]; optionsController.gridView = gmGridView; optionsController.contentSizeForViewInPopover = CGSizeMake(400, 500); _optionsNav = [[UINavigationController alloc] initWithRootViewController:optionsController]; if (INTERFACE_IS_PHONE) { UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithTitle:@"Done" style:UIBarButtonItemStyleDone target:self action:@selector(optionsDoneAction)]; optionsController.navigationItem.rightBarButtonItem = doneButton; }*/ }
public override void ViewDidLoad() { base.ViewDidLoad(); AppDelegate.NavigationBar.SetBackButtonOn(this); // Initialize the alternate list selector _listView = new SeriesListViewController(this); _listView.View.AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth; _listView.View.Frame = new RectangleF(0, 0, View.Frame.Width, View.Frame.Height); // Initialize the art gallery (already in background) _galleryView = new SeriesGalleryViewController(this, _listView); _galleryView.View.AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth; _galleryView.View.Frame = new RectangleF(0, 0, View.Frame.Width, View.Frame.Height); // http://stackoverflow.com/questions/1718495/why-does-viewdidappear-not-get-triggered this.View.AddSubview(AppGlobal.CollectionsViewInListMode ? _listView.View : _galleryView.View); // http://www.grokkingcocoa.com/a-simple-way-to-animate-a-u.html // http://ykyuen.wordpress.com/2010/06/11/iphone-adding-image-to-uibarbuttonitem/ var listViewImage = UIImage.FromBundle("Images/gallery/listView.png"); var listViewImageHighlighted = UIImage.FromBundle("Images/gallery/listViewHighlighted.png"); _buttonFrame = new RectangleF(0, 0, 29, 30); _buttonListThumb = new UIImageView(listViewImage); listViewImage.Dispose(); _buttonListThumb.Frame = _buttonFrame; _buttonListThumb.Hidden = AppGlobal.CollectionsViewInListMode; var buttonListHighlight = new UIImageView(listViewImageHighlighted); listViewImageHighlighted.Dispose(); buttonListHighlight.Frame = _buttonFrame; // Build a thumbnail button for the selected page's piece // TODO duplicate with code to select a piece in the list view // TODO shouldn't have to size something from a factory method! var thumb0 = ImageFactory.LoadRoundedThumbnail(_series.Pieces[_page]); var thumb1 = ImageHelper.ImageToFitSize(thumb0, _listViewImageSize); thumb0.Dispose(); _buttonGalleryThumb = new UIImageView(thumb1); thumb1.Dispose(); _buttonGalleryThumb.Hidden = !AppGlobal.CollectionsViewInListMode; _buttonGalleryThumb.Frame = _buttonFrame; // Wire up the flip button _buttonInner = UIButton.FromType(UIButtonType.Custom); _buttonInner.UserInteractionEnabled = true; _buttonInner.Bounds = _buttonListThumb.Bounds; _buttonInner.AddSubview(_buttonListThumb); _buttonInner.AddSubview(_buttonGalleryThumb); _buttonInner.AddTarget(delegate { _buttonInner.InsertSubviewAbove(_buttonListThumb, buttonListHighlight); buttonListHighlight.RemoveFromSuperview(); Flip(); }, UIControlEvent.TouchUpInside); _buttonInner.AddTarget(delegate { _buttonInner.InsertSubviewAbove(_buttonListThumb, buttonListHighlight); buttonListHighlight.RemoveFromSuperview(); Flip(); }, UIControlEvent.TouchUpOutside); _buttonInner.AddTarget(delegate { _buttonInner.InsertSubviewAbove(buttonListHighlight, _buttonListThumb); _buttonListThumb.RemoveFromSuperview(); }, UIControlEvent.TouchDown); // Wire up the series info button var info = UIButton.FromType(UIButtonType.InfoLight); info.UserInteractionEnabled = true; info.AddTarget((s, a)=> { ShowSeriesDetails(); }, UIControlEvent.TouchUpInside); _infoButton = new UIBarButtonItem(info); _listButton = new UIBarButtonItem(_buttonInner); LayoutBarButtonItems(); }
private void SetupUI() { var backButton = new UIButton (new RectangleF (0, 0, 25, 25)); backButton.SetBackgroundImage (UIImage.FromFile ("Images/General/BackButton.png"), UIControlState.Normal); backButton.SetBackgroundImage (UIImage.FromFile ("Images/General/BackButtonHighlighted.png"), UIControlState.Highlighted); backButton.AddTarget((object sender, EventArgs args) => NavigationController.PopViewControllerAnimated (true), UIControlEvent.TouchUpInside); var cancelButton = new UIButton (new RectangleF (0, 0, 25, 25)); cancelButton.SetBackgroundImage (UIImage.FromFile (Images.CancelButton), UIControlState.Normal); cancelButton.SetBackgroundImage (UIImage.FromFile (Images.CancelButtonHighlighted), UIControlState.Highlighted); cancelButton.AddTarget (HandleCancelButtonTapped, UIControlEvent.TouchUpInside); BackButton = new UIBarButtonItem (backButton); CancelButton = new UIBarButtonItem (cancelButton); NavigationController.NavigationItem.BackBarButtonItem = BackButton; NavigationItem.LeftBarButtonItem = CancelButton; NavigationController.NavigationBar.BarStyle = UIBarStyle.Black; NavigationBarLabel = InterfaceHelper.LabelForTitle ("SETTINGS"); TableView.BackgroundView = null; TableView.BackgroundColor = UIColor.FromPatternImage (UIImage.FromFile ("Images/General/TableBackground.png")); }