本文整理汇总了C#中UIButton.AddSubview方法的典型用法代码示例。如果您正苦于以下问题:C# UIButton.AddSubview方法的具体用法?C# UIButton.AddSubview怎么用?C# UIButton.AddSubview使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UIButton
的用法示例。
在下文中一共展示了UIButton.AddSubview方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SeriesPrimaryCell
public SeriesPrimaryCell( CGRect parentSize, UITableViewCellStyle style, string cellIdentifier, UIImage imagePlaceholder ) : base( style, cellIdentifier )
{
BackgroundColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BG_Layer_Color );
Image = new UIImageView( );
Image.ContentMode = UIViewContentMode.ScaleAspectFit;
Image.Layer.AnchorPoint = CGPoint.Empty;
// Banner Image
Image.Image = imagePlaceholder;
Image.SizeToFit( );
// resize the image to fit the width of the device
nfloat imageAspect = Image.Bounds.Height / Image.Bounds.Width;
Image.Frame = new CGRect( 0, 0, parentSize.Width, parentSize.Width * imageAspect );
AddSubview( Image );
// Create the title
Title = new UILabel( );
Title.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont( ControlStylingConfig.Font_Bold, ControlStylingConfig.Large_FontSize );
Title.Layer.AnchorPoint = CGPoint.Empty;
Title.TextColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.TextField_ActiveTextColor );
Title.BackgroundColor = UIColor.Clear;
Title.LineBreakMode = UILineBreakMode.TailTruncation;
Title.Text = "PLACEHOLDER PLACEHOLDER";
/*Title.SizeToFit( );
Title.Frame = new CGRect( 5, Image.Frame.Bottom + 5, parentSize.Width - 10, Title.Frame.Height + 5 );*/
AddSubview( Title );
// Date & Speaker
Date = new UILabel( );
Date.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont( ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize );
Date.Layer.AnchorPoint = CGPoint.Empty;
Date.TextColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.TextField_PlaceholderTextColor );
Date.BackgroundColor = UIColor.Clear;
Date.LineBreakMode = UILineBreakMode.TailTruncation;
Date.Text = "88/88/8888";
/*Date.SizeToFit( );
Date.Frame = new CGRect( 5, Title.Frame.Bottom - 5, parentSize.Width, Date.Frame.Height + 5 );*/
AddSubview( Date );
Speaker = new UILabel( );
Speaker.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont( ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize );
Speaker.Layer.AnchorPoint = CGPoint.Empty;
Speaker.TextColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.TextField_PlaceholderTextColor );
Speaker.BackgroundColor = UIColor.Clear;
Speaker.LineBreakMode = UILineBreakMode.TailTruncation;
Speaker.Text = "PLACEHOLDER";
/*Speaker.SizeToFit( );
Speaker.Frame = new CGRect( parentSize.Width - Speaker.Bounds.Width - 5, Title.Frame.Bottom - 5, parentSize.Width, Speaker.Frame.Height + 5 );*/
AddSubview( Speaker );
// Watch & Take Notes Buttons
WatchButton = new UIButton( UIButtonType.Custom );
WatchButton.TouchUpInside += (object sender, EventArgs e) => { Parent.WatchButtonClicked( ); };
WatchButton.Layer.AnchorPoint = CGPoint.Empty;
WatchButton.BackgroundColor = UIColor.Clear;
WatchButton.Layer.BorderColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BG_Layer_BorderColor ).CGColor;
WatchButton.Layer.BorderWidth = 1;
WatchButton.SizeToFit( );
AddSubview( WatchButton );
WatchButtonIcon = new UILabel( );
WatchButton.AddSubview( WatchButtonIcon );
WatchButtonIcon.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont( PrivateControlStylingConfig.Icon_Font_Secondary, PrivateNoteConfig.Series_Table_IconSize );
WatchButtonIcon.Text = PrivateNoteConfig.Series_Table_Watch_Icon;
WatchButtonIcon.SizeToFit( );
WatchButtonLabel = new UILabel( );
WatchButton.AddSubview( WatchButtonLabel );
WatchButtonLabel.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont( ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize );
WatchButtonLabel.Text = MessagesStrings.Series_Table_Watch;
WatchButtonLabel.SizeToFit( );
TakeNotesButton = new UIButton( UIButtonType.Custom );
TakeNotesButton.TouchUpInside += (object sender, EventArgs e) => { Parent.TakeNotesButtonClicked( ); };
TakeNotesButton.Layer.AnchorPoint = CGPoint.Empty;
TakeNotesButton.BackgroundColor = UIColor.Clear;
TakeNotesButton.Layer.BorderColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BG_Layer_BorderColor ).CGColor;
TakeNotesButton.Layer.BorderWidth = 1;
TakeNotesButton.SizeToFit( );
AddSubview( TakeNotesButton );
TakeNotesButtonIcon = new UILabel( );
TakeNotesButton.AddSubview( TakeNotesButtonIcon );
TakeNotesButtonIcon.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont( PrivateControlStylingConfig.Icon_Font_Secondary, PrivateNoteConfig.Series_Table_IconSize );
TakeNotesButtonIcon.Text = PrivateNoteConfig.Series_Table_TakeNotes_Icon;
TakeNotesButtonIcon.SizeToFit( );
TakeNotesButtonLabel = new UILabel( );
TakeNotesButton.AddSubview( TakeNotesButtonLabel );
TakeNotesButtonLabel.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont( ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize );
TakeNotesButtonLabel.Text = MessagesStrings.Series_Table_TakeNotes;
TakeNotesButtonLabel.SizeToFit( );
//.........这里部分代码省略.........
示例2: ViewDidLoad
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();
}
示例3: GetViewForHeader
public override UIView GetViewForHeader (UITableView tableView, nint section)
{
var btn = new UIButton (new CGRect (0, 0, tableView.Frame.Width, CollapsibleListViewCell.HEIGHT));
btn.TitleEdgeInsets = new UIEdgeInsets (btn.TitleEdgeInsets.Top, CollapsibleListViewCell.ParentItemLeftPadding, btn.TitleEdgeInsets.Bottom, btn.TitleEdgeInsets.Right);
btn.AutoresizingMask = UIViewAutoresizing.All;
//set section header right side image
if (!string.IsNullOrEmpty (Settings [(int)section].SelectedStateIcon) && !string.IsNullOrEmpty (Settings [(int)section].DeselectedStateIcon)) {
var btnImg = btn.ViewWithTag ((int)section);
if (btnImg != null) {
btnImg.RemoveFromSuperview ();
}
var img = !Settings [(int)section].IsSelected ? new UIImageView (UIImage.FromBundle (Settings [(int)section].DeselectedStateIcon)) : new UIImageView (UIImage.FromBundle (Settings [(int)section].SelectedStateIcon));
img.Tag = (int)section;
img.Frame = new CGRect (
btn.Frame.Width - CollapsibleListViewCell.HEIGHT - 20,
0,
CollapsibleListViewCell.HEIGHT,
CollapsibleListViewCell.HEIGHT
);
img.ContentMode = UIViewContentMode.Center;
img.AutoresizingMask = UIViewAutoresizing.FlexibleLeftMargin;
//img.BackgroundColor = UIColor.Yellow;
btn.AddSubview (img);
}
//ADD SEPERATOR LINE AT BOTTOM
var seperatorLine = new UIView (new CGRect (0, CollapsibleListViewCell.HEIGHT - 1, tableView.Frame.Width, 1));
seperatorLine.BackgroundColor = UIColor.LightGray;
seperatorLine.Alpha = 0.3f;
seperatorLine.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
btn.AddSubview (seperatorLine);
btn.SetTitle (Settings [(int)section].Title, UIControlState.Normal);
btn.Font = UIFont.BoldSystemFontOfSize (CollapsibleListViewCell.FontSize);
btn.BackgroundColor = UIColor.Clear;
btn.HorizontalAlignment = UIControlContentHorizontalAlignment.Left;
btn.SetTitleColor (UIColor.DarkGray, UIControlState.Normal);
btn.TouchUpInside += (sender, e) => {
//put in your code to toggle your boolean value here
if (Settings [(int)section].OnClickListener != null) {
Settings [(int)section].OnClickListener.Invoke (Settings [(int)section]);
}
Settings [(int)section].IsSelected = !Settings [(int)section].IsSelected;
///reload this section
tableView.ReloadSections (NSIndexSet.FromIndex (section), UITableViewRowAnimation.Fade);
};
return btn;
}
示例4: SetupPencilUI
void SetupPencilUI ()
{
pencilButton = AddButton ("pencil", StopPencilButtonAction);
pencilButton.TitleLabel.TextAlignment = UITextAlignment.Left;
var bounds = pencilButton.Bounds;
var dimension = bounds.Height - 16;
pencilButton.ContentEdgeInsets = new UIEdgeInsets (0, dimension, 0, 0);
var x = bounds.GetMinX () + 3;
var y = bounds.GetMinY () + (bounds.Height - dimension) - 7;
var closeImg = UIImage.FromBundle ("Close");
var imageView = (closeImg != null) ? new UIImageView (closeImg) : new UIImageView ();
imageView.Frame = new CGRect (x, y, dimension, dimension);
imageView.Alpha = 0.7f;
pencilButton.AddSubview (imageView);
PencilMode = false;
NSObject observer = UIApplication.Notifications.ObserveWillEnterForeground ((sender, e) => {
if (PencilMode
&& (!LastSeenPencilInteraction.HasValue || (DateTime.Now.Ticks - LastSeenPencilInteraction.Value) > pencilResetInterval))
StopPencilButtonAction (this, EventArgs.Empty);
});
observers.Add (observer);
}
示例5: ViewDidLoad
public override void ViewDidLoad()
{
base.ViewDidLoad();
// Background mask
BackgroundPanel = new UIView( );
BackgroundPanel.BackgroundColor = UIColor.Black;
BackgroundPanel.Layer.Opacity = 0.00f;
View.AddSubview( BackgroundPanel );
// Floating "main" UI panel
MainPanel = new UIView();
MainPanel.Layer.AnchorPoint = CGPoint.Empty;
MainPanel.BackgroundColor = Theme.GetColor( Config.Instance.VisualSettings.SidebarBGColor );//Theme.GetColor( Config.Instance.VisualSettings.TopHeaderBGColor );
MainPanel.Layer.Opacity = 1.00f;
MainPanel.ClipsToBounds = true;
View.AddSubview( MainPanel );
// Scroll view on the right hand side
ScrollView = new UIScrollViewWrapper( );
ScrollView.Layer.AnchorPoint = CGPoint.Empty;
ScrollView.Parent = this;
ScrollView.BackgroundColor = Theme.GetColor( Config.Instance.VisualSettings.BackgroundColor );
MainPanel.AddSubview( ScrollView );
// setup controls that go on the left side
AdultChildToggle = new UIToggle( Strings.General_Adult, Strings.General_Child,
delegate(bool wasLeft)
{
if( wasLeft == true )
{
SwitchActiveMemberView( AdultPanel );
}
else
{
SwitchActiveMemberView( ChildPanel );
}
} );
Theme.StyleToggle( AdultChildToggle, Config.Instance.VisualSettings.ToggleStyle );
AdultChildToggle.Font = FontManager.GetFont( Settings.General_RegularFont, Config.Instance.VisualSettings.SmallFontSize );
AdultChildToggle.Layer.AnchorPoint = CGPoint.Empty;
MainPanel.AddSubview( AdultChildToggle );
// setup our submit button
SubmitButton = UIButton.FromType( UIButtonType.System );
SubmitButton.Layer.AnchorPoint = CGPoint.Empty;
SubmitButton.Font = FontManager.GetFont( Settings.General_RegularFont, Config.Instance.VisualSettings.SmallFontSize );
SubmitButton.SetTitle( Strings.General_Save, UIControlState.Normal );
SubmitButton.BackgroundColor = UIColor.Blue;
SubmitButton.SizeToFit( );
Theme.StyleButton( SubmitButton, Config.Instance.VisualSettings.PrimaryButtonStyle );
SubmitButton.Bounds = new CGRect( 0, 0, SubmitButton.Bounds.Width * 2.00f, SubmitButton.Bounds.Height );
MainPanel.AddSubview( SubmitButton );
SubmitButton.TouchUpInside += (object sender, EventArgs e ) =>
{
TrySubmitPerson( );
};
// setup the button to tap for editing the picture
EditPictureButton = new UIButton( new CGRect( 0, 0, 112, 112 ) );
EditPictureButton.Layer.AnchorPoint = CGPoint.Empty;
EditPictureButton.Font = FontManager.GetFont( Settings.AddPerson_Icon_Font_Primary, Settings.AddPerson_SymbolFontSize );
EditPictureButton.SetTitleColor( Theme.GetColor( Config.Instance.VisualSettings.PhotoOutlineColor ), UIControlState.Normal );
EditPictureButton.Layer.BorderColor = Theme.GetColor( Config.Instance.VisualSettings.PhotoOutlineColor ).CGColor;
EditPictureButton.Layer.CornerRadius = EditPictureButton.Bounds.Width / 2;
EditPictureButton.Layer.BorderWidth = 4;
MainPanel.AddSubview( EditPictureButton );
EditPictureButton.TouchUpInside += (object sender, EventArgs e ) =>
{
Parent.CaptureImage( delegate(NSData imageBuffer )
{
// if an image was taken, flag this as dirty so
// we know to upload it.
if( imageBuffer != null )
{
ProfileImageViewDirty = true;
UpdateProfilePic( imageBuffer );
}
});
};
// set the profile image mask so it's circular
CALayer maskLayer = new CALayer();
maskLayer.AnchorPoint = new CGPoint( 0, 0 );
maskLayer.Bounds = EditPictureButton.Layer.Bounds;
maskLayer.CornerRadius = EditPictureButton.Bounds.Width / 2;
maskLayer.BackgroundColor = UIColor.Black.CGColor;
EditPictureButton.Layer.Mask = maskLayer;
//
// setup the image that will display (and note it's a child of EditPictureButton)
ProfileImageView = new UIImageView( );
ProfileImageView.ContentMode = UIViewContentMode.ScaleAspectFit;
ProfileImageView.Layer.AnchorPoint = CGPoint.Empty;
ProfileImageView.Bounds = EditPictureButton.Bounds;
ProfileImageView.Layer.Position = CGPoint.Empty;
EditPictureButton.AddSubview( ProfileImageView );
//.........这里部分代码省略.........
示例6: ViewDidLoad
public override void ViewDidLoad()
{
base.ViewDidLoad();
BlockerView = new UIBlockerView( View, View.Frame.ToRectF( ) );
View.BackgroundColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BackgroundColor );
ScrollView = new UIScrollViewWrapper();
ScrollView.Parent = this;
ScrollView.Layer.AnchorPoint = CGPoint.Empty;
ScrollView.Bounds = View.Bounds;
View.AddSubview( ScrollView );
UserNameField = new StyledTextField();
ScrollView.AddSubview( UserNameField.Background );
UserNameField.Field.AutocapitalizationType = UITextAutocapitalizationType.None;
UserNameField.Field.AutocorrectionType = UITextAutocorrectionType.No;
ControlStyling.StyleTextField( UserNameField.Field, LoginStrings.UsernamePlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize );
ControlStyling.StyleBGLayer( UserNameField.Background );
UserNameField.Field.ShouldReturn += (textField) =>
{
textField.ResignFirstResponder();
TryRockBind();
return true;
};
PasswordField = new StyledTextField();
ScrollView.AddSubview( PasswordField.Background );
PasswordField.Field.AutocorrectionType = UITextAutocorrectionType.No;
PasswordField.Field.SecureTextEntry = true;
ControlStyling.StyleTextField( PasswordField.Field, LoginStrings.PasswordPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize );
ControlStyling.StyleBGLayer( PasswordField.Background );
PasswordField.Field.ShouldReturn += (textField) =>
{
textField.ResignFirstResponder();
TryRockBind();
return true;
};
// obviously attempt a login if login is pressed
LoginButton = UIButton.FromType( UIButtonType.System );
ScrollView.AddSubview( LoginButton );
ControlStyling.StyleButton( LoginButton, LoginStrings.LoginButton, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize );
LoginButton.SizeToFit( );
LoginButton.TouchUpInside += (object sender, EventArgs e) =>
{
if( RockMobileUser.Instance.LoggedIn == true )
{
RockMobileUser.Instance.LogoutAndUnbind( );
SetUIState( LoginState.Out );
}
else
{
TryRockBind();
}
};
AdditionalOptions = new UILabel( );
ScrollView.AddSubview( AdditionalOptions );
ControlStyling.StyleUILabel( AdditionalOptions, ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize );
AdditionalOptions.Text = LoginStrings.AdditionalOptions;
AdditionalOptions.TextColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.TextField_PlaceholderTextColor );
AdditionalOptions.SizeToFit( );
OrSpacerLabel = new UILabel( );
ScrollView.AddSubview( OrSpacerLabel );
ControlStyling.StyleUILabel( OrSpacerLabel, ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize );
OrSpacerLabel.TextColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.TextField_PlaceholderTextColor );
OrSpacerLabel.Text = LoginStrings.OrString;
OrSpacerLabel.SizeToFit( );
RegisterButton = UIButton.FromType( UIButtonType.System );
ScrollView.AddSubview( RegisterButton );
ControlStyling.StyleButton( RegisterButton, LoginStrings.RegisterButton, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize );
//RegisterButton.BackgroundColor = UIColor.Clear;
RegisterButton.SizeToFit( );
RegisterButton.TouchUpInside += (object sender, EventArgs e ) =>
{
Springboard.RegisterNewUser( );
};
// setup the result
LoginResult = new StyledTextField( );
ScrollView.AddSubview( LoginResult.Background );
ControlStyling.StyleTextField( LoginResult.Field, "", ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize );
ControlStyling.StyleBGLayer( LoginResult.Background );
LoginResult.Field.UserInteractionEnabled = false;
LoginResult.Field.TextAlignment = UITextAlignment.Center;
// setup the facebook button
FacebookLogin = new UIButton( );
ScrollView.AddSubview( FacebookLogin );
string imagePath = NSBundle.MainBundle.BundlePath + "/" + "facebook_login.png";
//.........这里部分代码省略.........
示例7: ViewDidLoad
public override void ViewDidLoad()
{
base.ViewDidLoad( );
TraitSize = UIScreen.MainScreen.Bounds.Size;
CurrentTraitCollection = TraitCollection;
// if we're on an iphone and they're holding it landscape, force a portrait traitsize
if ( UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone && IsDeviceLandscape( ) )
{
UITraitCollection horzTrait = UITraitCollection.FromHorizontalSizeClass( UIUserInterfaceSizeClass.Compact );
UITraitCollection vertTrait = UITraitCollection.FromVerticalSizeClass( UIUserInterfaceSizeClass.Regular );
CurrentTraitCollection = UITraitCollection.FromTraitsFromCollections( new UITraitCollection[] { horzTrait, vertTrait } );
TraitSize = new CGSize( TraitSize.Height, TraitSize.Width );
}
View.Layer.AnchorPoint = CGPoint.Empty;
View.Bounds = new CGRect( View.Bounds.Left, View.Bounds.Top, TraitSize.Width, TraitSize.Height );
// create the login controller / profile view controllers
LoginViewController = new LoginViewController( );
LoginViewController.Springboard = this;
ProfileViewController = new ProfileViewController( );
ProfileViewController.Springboard = this;
ImageCropViewController = new ImageCropViewController( );
ImageCropViewController.Springboard = this;
RegisterViewController = new RegisterViewController( );
RegisterViewController.Springboard = this;
OOBEViewController = new OOBEViewController( );
OOBEViewController.Springboard = this;
OOBEViewController.View.Layer.Position = CGPoint.Empty;
SplashViewController = new SplashViewController( );
SplashViewController.Springboard = this;
SplashViewController.View.Layer.Position = CGPoint.Empty;
ScrollView = new UIScrollViewWrapper( );
ScrollView.Layer.AnchorPoint = CGPoint.Empty;
ScrollView.Parent = this;
View.AddSubview( ScrollView );
// Instantiate all activities
float elementWidth = 250;
float elementHeight = 45;
NewsElement = new UIView( new CGRect( 0, 0, elementWidth, elementHeight ) );
ScrollView.AddSubview( NewsElement );
MessagesElement = new UIView( new CGRect( 0, 0, elementWidth, elementHeight ) );
ScrollView.AddSubview( MessagesElement );
GiveElement = new UIView( new CGRect( 0, 0, elementWidth, elementHeight ) );
ScrollView.AddSubview( GiveElement );
ConnectElement = new UIView( new CGRect( 0, 0, elementWidth, elementHeight ) );
ScrollView.AddSubview( ConnectElement );
PrayerElement = new UIView( new CGRect( 0, 0, elementWidth, elementHeight ) );
ScrollView.AddSubview( PrayerElement );
MoreElement = new UIView( new CGRect( 0, 0, elementWidth, elementHeight ) );
ScrollView.AddSubview( MoreElement );
//
EditPictureButton = new UIButton( new CGRect( 0, 0, 112, 112 ) );
ScrollView.AddSubview( EditPictureButton );
WelcomeField = new UILabel();
ScrollView.AddSubview( WelcomeField );
UserNameField = new UILabel();
ScrollView.AddSubview( UserNameField );
ViewProfileButton = new UIButton();
ScrollView.AddSubview( ViewProfileButton );
ViewProfileLabel = new UILabel();
ScrollView.AddSubview( ViewProfileLabel );
Elements.Add( new SpringboardElement( this, new NewsTask( "NewsStoryboard_iPhone" ) , NewsElement , SpringboardConfig.Element_News_Icon , SpringboardStrings.Element_News_Title ) );
Elements.Add( new SpringboardElement( this, new NotesTask( "NotesStoryboard_iPhone" ) , MessagesElement, SpringboardConfig.Element_Messages_Icon, SpringboardStrings.Element_Messages_Title ) );
Elements.Add( new SpringboardElement( this, new GiveTask( "GiveStoryboard_iPhone" ) , GiveElement , SpringboardConfig.Element_Give_Icon , SpringboardStrings.Element_Give_Title ) );
Elements.Add( new SpringboardElement( this, new ConnectTask( "ConnectStoryboard_iPhone" ), ConnectElement , SpringboardConfig.Element_Connect_Icon , SpringboardStrings.Element_Connect_Title ) );
Elements.Add( new SpringboardElement( this, new PrayerTask( "PrayerStoryboard_iPhone" ) , PrayerElement , SpringboardConfig.Element_Prayer_Icon , SpringboardStrings.Element_Prayer_Title ) );
Elements.Add( new SpringboardElement( this, new AboutTask( "" ) , MoreElement , SpringboardConfig.Element_More_Icon , SpringboardStrings.Element_More_Title ) );
// add a bottom seperator for the final element
BottomSeperator = new UIView();
BottomSeperator.BackgroundColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BG_Layer_Color );
ScrollView.AddSubview( BottomSeperator );
BottomSeperator.Frame = new CGRect( 0, 0, View.Frame.Width, 1.0f );
//.........这里部分代码省略.........
示例8: PersonEntry
public PersonEntry( string personName, int personId, bool canCheckin, string roleInFamily, List<Rock.Client.GroupMember> primaryFamilyMembers )
{
PrimaryFamilyMembers = primaryFamilyMembers;
PersonId = personId;
CanCheckin = canCheckin;
Button = new UIButton( UIButtonType.System );
Button.Layer.AnchorPoint = CGPoint.Empty;
Button.Layer.CornerRadius = 4;
Button.Bounds = new CGRect( 0, 0, PersonEntryWidth, PersonEntryHeight );
Name = new UILabel( );
Name.Layer.AnchorPoint = CGPoint.Empty;
Name.Text = personName;
Name.SizeToFit( );
Name.TextColor = Theme.GetColor( Config.Instance.VisualSettings.PrimaryButtonStyle.TextColor );
Button.AddSubview( Name );
AgeLabel = new UILabel( );
AgeLabel.Layer.AnchorPoint = CGPoint.Empty;
AgeLabel.Text = roleInFamily;
AgeLabel.TextColor = Theme.GetColor( Config.Instance.VisualSettings.PrimaryButtonStyle.TextColor );
AgeLabel.Font = FontManager.GetFont( Settings.General_LightFont, Config.Instance.VisualSettings.SmallFontSize );
AgeLabel.SizeToFit( );
Button.AddSubview( AgeLabel );
nfloat combinedHeight = Name.Layer.Bounds.Height + AgeLabel.Bounds.Height;
nfloat startingY = (PersonEntryHeight - combinedHeight) / 2;
Name.Layer.Position = new CGPoint( (PersonEntryWidth - Name.Bounds.Width) / 2, startingY );
AgeLabel.Layer.Position = new CGPoint( (PersonEntryWidth - AgeLabel.Bounds.Width) / 2, Name.Frame.Bottom );
Button.TouchUpInside += (object sender, EventArgs e) =>
{
Button.Enabled = false;
// are they currently able to check in?
if( CanCheckin == true )
{
// then remove it.
int pendingRemovals = 0;
foreach( Rock.Client.GroupMember member in primaryFamilyMembers )
{
FamilyManagerApi.RemoveKnownRelationship( member.Person.Id, PersonId, Config.Instance.CanCheckInGroupRole.Id, delegate
{
// once we hear back from all the requests, toggle the button
pendingRemovals++;
if( pendingRemovals == primaryFamilyMembers.Count )
{
Button.Enabled = true;
CanCheckin = !CanCheckin;
UpdateBGColor( );
Button.SetNeedsDisplay( );
}
});
}
}
else
{
// simply bind them to the first person
FamilyManagerApi.UpdateKnownRelationship( primaryFamilyMembers[ 0 ].Person.Id, PersonId, Config.Instance.CanCheckInGroupRole.Id, delegate
{
Button.Enabled = true;
CanCheckin = !CanCheckin;
UpdateBGColor( );
Button.SetNeedsDisplay( );
});
}
};
UpdateBGColor( );
}
示例9: UpdateImage
private void UpdateImage(string imageName, int widthRequest, int heightRequest, UIButton targetButton)
{
var assembly = typeof(App).GetTypeInfo().Assembly;
UIImage image = null;
if (imageName != null)
{
try
{
image = UIImage.FromResource(assembly, imageName);
}
catch (Exception)
{
var path = PCLStorage.FileSystem.Current.LocalStorage.Path;
var iPath = PCLStorage.PortablePath.Combine(path, imageName);
image = UIImage.FromFile(iPath);
}
}
var imageView = new UIImageView();
var widthCt = NSLayoutConstraint.Create(imageView, NSLayoutAttribute.Width, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1, widthRequest);
var heightCt = NSLayoutConstraint.Create(imageView, NSLayoutAttribute.Height, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1, heightRequest);
imageView.AddConstraint(widthCt);
imageView.AddConstraint(heightCt);
imageView.TranslatesAutoresizingMaskIntoConstraints = false;
imageView.Image = image;
imageView.ContentMode = UIViewContentMode.ScaleAspectFit;
targetButton.AddSubview(imageView);
switch (ImageButton.Orientation)
{
case TextAligment.Left:
{
targetButton.TitleEdgeInsets = new UIEdgeInsets(0, 20, 0, 0);
targetButton.HorizontalAlignment = UIControlContentHorizontalAlignment.Left;
}
break;
case TextAligment.Top:
{
targetButton.TitleEdgeInsets = new UIEdgeInsets(5, 0, 0, 0);
targetButton.VerticalAlignment = UIControlContentVerticalAlignment.Top;
}
break;
case TextAligment.Right:
{
var yCenterCt = NSLayoutConstraint.Create(imageView, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, targetButton, NSLayoutAttribute.CenterY, 1, 0);
var xLeftCt = NSLayoutConstraint.Create(imageView, NSLayoutAttribute.Left, NSLayoutRelation.Equal, targetButton, NSLayoutAttribute.Left, 1, 0);
targetButton.AddConstraint(yCenterCt);
targetButton.AddConstraint(xLeftCt);
targetButton.TitleEdgeInsets = new UIEdgeInsets(0, 0, 0, 20);
targetButton.HorizontalAlignment = UIControlContentHorizontalAlignment.Right;
}
break;
case TextAligment.Bottom:
{
var xCenterCt = NSLayoutConstraint.Create(imageView, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, targetButton, NSLayoutAttribute.CenterX, 1, 0);
var yTopCt = NSLayoutConstraint.Create(imageView, NSLayoutAttribute.Top, NSLayoutRelation.Equal, targetButton, NSLayoutAttribute.Top, 1, 0);
targetButton.AddConstraint(xCenterCt);
targetButton.AddConstraint(yTopCt);
targetButton.TitleEdgeInsets = new UIEdgeInsets(0, 0, 5, 0);
targetButton.VerticalAlignment = UIControlContentVerticalAlignment.Bottom;
}
break;
default:
throw new InvalidOperationException();
}
}