本文整理汇总了C#中UIView.RemoveFromSuperview方法的典型用法代码示例。如果您正苦于以下问题:C# UIView.RemoveFromSuperview方法的具体用法?C# UIView.RemoveFromSuperview怎么用?C# UIView.RemoveFromSuperview使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UIView
的用法示例。
在下文中一共展示了UIView.RemoveFromSuperview方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ViewDidLoad
public override void ViewDidLoad()
{
base.ViewDidLoad();
View.BackgroundColor = UIColor.White;
View.AutoresizingMask = UIViewAutoresizing.FlexibleDimensions;
// Adjust taps/touches required to fit your needs.
UITapGestureRecognizer tapRecognizer = new UITapGestureRecognizer() {
NumberOfTapsRequired = 1,
NumberOfTouchesRequired = 1,
};
tapRecognizer.AddTarget((sender) => {
// The foreach is only necessary if you have more than one touch for your recognizer.
// For all else just roll with zero, `PointF location = tapRecognizer.LocationOfTouch(0, View);`
foreach (int locationIndex in Enumerable.Range(0, tapRecognizer.NumberOfTouches)) {
PointF location = tapRecognizer.LocationOfTouch(locationIndex, View);
UIView newTapView = new UIView(new RectangleF(PointF.Empty, ItemSize)) {
BackgroundColor = GetRandomColor(),
};
newTapView.Center = location;
View.Add(newTapView);
// Remove the view after it's been around a while.
Task.Delay(5000).ContinueWith(_ => InvokeOnMainThread(() => {
newTapView.RemoveFromSuperview();
newTapView.Dispose();
}));
}
});
View.AddGestureRecognizer(tapRecognizer);
}
示例2: FadeToView
private void FadeToView(UIView fromView, UIView toView)
{
UIView.Animate(0.15, 0, UIViewAnimationOptions.CurveEaseIn, () => fromView.Alpha = 0, () => {
fromView.RemoveFromSuperview();
toView.Alpha = 0;
ContentView.Add(toView);
UIView.Animate(0.15, 0, UIViewAnimationOptions.CurveEaseOut, () => toView.Alpha = 1, null);
});
}
示例3: TSCustomNavController
public TSCustomNavController ()
{
MenuButton = new UIButton (new CGRect (10, 5, 25, 25));
MenuButton.SetImage (new UIImage ("menu_icon.png"), UIControlState.Normal);
mainView = new UIView (new CGRect (0.0f, 64.0f, 275, 0));
logoutVIew = new UIView (new CGRect (0.0f, 0.0f, 275, 150));
// it's use to display user name for iPhone
// if (TSPhoneSpec.UserInterfaceIsPhone) {
// lblName = new UIButton (new CGRect (MenuButton.Frame.X + MenuButton.Frame.Width + 5, 5, 130, 30));
// // lblName.SetTitle("John Anderson",UIControlState.Normal);
// lblName.Font = UIFont.SystemFontOfSize(15.0f);
// lblName.SetTitleColor (UIColor.DarkGray, UIControlState.Normal);
// } else {
imgUser = new UIImageView (new CGRect (MenuButton.Frame.X + MenuButton.Frame.Width + 5, 5, 30, 30));
imgUser.Image = new UIImage ("user_icon.png");
imgUser.Layer.CornerRadius = 17;
imgUser.ClipsToBounds = true;
this.NavigationBar.AddSubview (imgUser);
lblName = new UIButton (new CGRect (imgUser.Frame.X + imgUser.Frame.Width + 5, 5, 130, 30));
// lblName.SetTitle("John Anderson",UIControlState.Normal);
lblName.Font = UIFont.SystemFontOfSize(15.0f);
lblName.SetTitleColor (UIColor.DarkGray, UIControlState.Normal);
// }
lblName.TouchUpInside += (object sender, EventArgs e) => {
Console.WriteLine("BtnClicked");
if(mainView.Frame.Height == 0){
logOutView();
// var obj= new TSUserLogoutView();
// AddLogOutView(obj.getUserLogoutView ());
}else{
mainView.Frame = new CGRect (0.0f, 64.0f, 275, 0.0f);
mainView.RemoveFromSuperview();
logoutVIew.RemoveFromSuperview();
}
};
SearchButton = new UIButton (new CGRect (TSPhoneSpec.ScreenWidth - 70, 40, 60, 30));
SearchButton.SetBackgroundImage (new UIImage ("logo.PNG"), UIControlState.Normal);
txtSearch = new UITextField (new CGRect (20, 5, 200, 30));
// this.View.AddSubview (logoutVIew);
this.NavigationBar.AddSubview (MenuButton);
this.NavigationBar.AddSubview (SearchButton);
this.NavigationBar.AddSubview (lblName);
this.NavigationBar.BackgroundColor = UIColor.FromRGB (255, 255, 255);
setLogoutView ();
}
示例4: RunDebugUI
void RunDebugUI()
{
var rect = new RectangleF (10, 20, 280, 400);
var top = new UIView (rect){
BackgroundColor = UIColor.FromRGBA (0, 0, 0, 100)
};
var button = UIButton.FromType (UIButtonType.RoundedRect);
button.Frame = new RectangleF (10, 340, 80, 36);
button.SetTitle ("Done", UIControlState.Normal);
button.TouchDown += delegate {
top.RemoveFromSuperview ();
timer.Dispose ();
};
top.AddSubview (button);
rect = new RectangleF (5, 5, 270, 350);
var dbg = new ImageLoaderDebug (rect);
top.AddSubview (dbg);
window.AddSubview (top);
timer = new System.Threading.Timer (x => { BeginInvokeOnMainThread (dbg.Layout); }, null, 500, 500);
}
示例5: AnimateTransition
public override void AnimateTransition(IUIViewControllerContextTransitioning transitionContext,
UIViewController fromViewController, UIViewController toViewController,
UIView fromView, UIView toView)
{
UIView containerView = transitionContext.ContainerView;
containerView.AddSubview (toView);
containerView.SendSubviewToBack (toView);
double duration = TransitionDuration (transitionContext);
NSAction animation = () => {
fromView.Alpha = 0f;
};
UIView.Animate (duration, animation, () => {
if (transitionContext.TransitionWasCancelled) {
fromView.Alpha = 1f;
} else {
fromView.RemoveFromSuperview ();
fromView.Alpha = 1f;
}
transitionContext.CompleteTransition (!transitionContext.TransitionWasCancelled);
});
}
示例6: Scrolled
public override void Scrolled(UIScrollView scrollView)
{
if (scrollView.Dragging && _controller.HasMorePages && _controller.EnableInfinitePaging)
{
float threshold = scrollView.ContentSize.Height - scrollView.Bounds.Height;
if (scrollView.ContentOffset.Y > threshold - 160 && !_controller._pagingActionInProgress)
{
Console.WriteLine("starting infinite loading");
_controller._pagingActionInProgress = true;
var existingInset = scrollView.ContentInset;
float bottom = existingInset.Bottom;
existingInset.Bottom += 60;
scrollView.ContentInset = existingInset;
var view = new UIView(new RectangleF(0, scrollView.ContentSize.Height, scrollView.Bounds.Width, 60));
scrollView.Add(view);
var indicator = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.Gray);
indicator.Center = new PointF(view.Bounds.Width / 2, view.Bounds.Height / 2);
indicator.HidesWhenStopped = true;
indicator.StartAnimating();
view.Add(indicator);
_controller._tableView.BeginUpdates();
int position = _controller._items[0].Item2.Count;
_controller.InfinitePagingAction(addedCount => {
Console.WriteLine ("inside infinite paging action");
indicator.StopAnimating();
view.RemoveFromSuperview();
var ex = scrollView.ContentInset;
ex.Bottom = bottom;
scrollView.ContentInset = ex;
_controller._tableView.InsertRows(Enumerable.Range(position, addedCount).Select(r => NSIndexPath.FromRowSection(r, _controller.PagingSectionIndex)).ToArray(), UITableViewRowAnimation.Fade);
_controller._tableView.EndUpdates();
NSTimer.CreateScheduledTimer(1, delegate {
_controller._pagingActionInProgress = false;
});
});
}
}
}
示例7: displayToastWithMessage
public void displayToastWithMessage(NSString toastMessage,NSString typeLabel)
{
UIWindow keyWindow = UIApplication.SharedApplication.KeyWindow;
if(toastView!=null)
{
toastView.RemoveFromSuperview();
}
toastView = new UIView ();
UILabel label1 = new UILabel ();
UILabel label2=new UILabel ();
label1.TextColor = label2.TextColor = UIColor.White;
label1.Font = UIFont.SystemFontOfSize (16);
label1.Text= toastMessage;
label2.Text = typeLabel;
label2.Font =UIFont.SystemFontOfSize (12);
label1.TextAlignment = label2.TextAlignment = UITextAlignment.Center;;
toastView.AddSubview (label1);
toastView.AddSubview (label2);
toastView.Alpha =1;
toastView.BackgroundColor = UIColor.Black.ColorWithAlpha (0.7f);
toastView.Layer.CornerRadius = 10;
CGSize expectedLabelSize1= toastMessage.GetSizeUsingAttributes (new UIStringAttributes() { Font = label1.Font });
CGSize expectedLabelSize2= typeLabel.GetSizeUsingAttributes (new UIStringAttributes() { Font = label2.Font });
keyWindow.AddSubview(toastView);
toastView.Frame = new CGRect(0.0f, 0.0f, Math.Max(expectedLabelSize1.Width, expectedLabelSize2.Width)+20, 45.0f);
label1.Frame = new CGRect(0.0f, 5.0f, Math.Max(expectedLabelSize1.Width, expectedLabelSize2.Width)+15, 15.0f);
label2.Frame = new CGRect(0.0f, 25.0f, Math.Max(expectedLabelSize1.Width, expectedLabelSize2.Width)+15, 15.0f);
toastView.Center = markerView.Center;
UIView.Animate (4, 0, UIViewAnimationOptions.CurveEaseInOut,
() => {
toastView.Alpha= 0.7f;
},
() => {
toastView.RemoveFromSuperview();
}
);
}
示例8: HandleLongPressGesture
protected override void HandleLongPressGesture()
{
switch (LongPressGestureRecognizer.State)
{
case UIGestureRecognizerState.Began:
{
// we try to grab the current seelected item and draw a floating copy of it on the Drag Surface
// the copy is just an image of it using RasterizedImage
var currentIndexPath = CollectionView.IndexPathForItemAtPoint(LongPressGestureRecognizer.LocationInView(CollectionView));
SelectedItemIndexPath = currentIndexPath;
if (SelectedItemIndexPath == null)
return;
if (!DataSource.CanMoveItemAtIndexPath(SelectedItemIndexPath))
return;
var collectionViewCell = CollectionView.CellForItem(SelectedItemIndexPath);
var tpoint = DragSurface.ConvertPointFromView(collectionViewCell.Frame.Location, CollectionView);
RectangleF frame = new RectangleF(tpoint.X, tpoint.Y, collectionViewCell.Frame.Size.Width, collectionViewCell.Frame.Size.Height);
CurrentView = new UIView(frame);
collectionViewCell.Highlighted = true;
var highlightedImageView = new UIImageView(RastertizedImage(collectionViewCell));
highlightedImageView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
highlightedImageView.Alpha = 1.0f;
collectionViewCell.Highlighted = false;
var imageView = new UIImageView(RastertizedImage(collectionViewCell));
imageView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
imageView.Alpha = 0.0f;
CurrentView.AddSubview(imageView);
CurrentView.AddSubview(highlightedImageView);
DragSurface.AddSubview(CurrentView); // add this to the top level view so that we can drag outside
CurrentViewCenter = CurrentView.Center;
OnWillBeginDraggingItem(SelectedItemIndexPath);
// we animate the drawing out of the floating copy
UIView.Animate(0.3, 0.0, UIViewAnimationOptions.BeginFromCurrentState,
() =>
{
CurrentView.Transform = CGAffineTransform.MakeScale(1.1f, 1.1f);
highlightedImageView.Alpha = 0.0f;
imageView.Alpha = 1.0f;
},
() =>
{
highlightedImageView.RemoveFromSuperview();
OnDidBegingDraggingItem(SelectedItemIndexPath);
});
InvalidateLayout();
}
break;
case UIGestureRecognizerState.Cancelled:
case UIGestureRecognizerState.Ended:
{
var currentIndexPath = SelectedItemIndexPath;
if (currentIndexPath == null || CurrentView == null)
return;
SelectedItemIndexPath = null;
CurrentViewCenter = PointF.Empty;
OnWillEndDraggingItem(currentIndexPath);
UIView.Animate(0.3, 0.0, UIViewAnimationOptions.BeginFromCurrentState,
() =>
{
var layoutAttributes = this.LayoutAttributesForItem(currentIndexPath);
CurrentView.Transform = CGAffineTransform.MakeScale(1.0f, 1.0f);
CurrentView.Center = CollectionView.ConvertPointToView(layoutAttributes.Center, DragSurface);
},
() =>
{
CurrentView.RemoveFromSuperview();
CurrentView = null;
InvalidateLayout();
OnDidEndDraggingItem(currentIndexPath);
});
}
break;
}
}
示例9: RemoveView
public void RemoveView(UIView view)
{
view.RemoveFromSuperview();
if (this.Subviews.Length == 0)
{
this.Hidden = true;
_previousKeyWindow.MakeKeyWindow();
//_previousKeyWindow release];
_previousKeyWindow = null;
}
else
{
UIView topView = this.Subviews.Last();
if (topView is UIImageView)
{
// It's a background. Remove it too
topView.RemoveFromSuperview();
}
this.Subviews.Last().UserInteractionEnabled = true;
}
}
示例10:
/// <summary>
/// Removes the view.
/// </summary>
/// <param name="view">View.</param>
void IMapControlHost.RemoveView(UIView view)
{
view.RemoveFromSuperview();
}
示例11: ViewDidLoad
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
AnimateView animateView = new AnimateView();
//TODO: more info at: http://www.youtube.com/watch?v=6JePwHjVj6U
//MODAL PRESENTATION OF UIVIEW CONTROLLER--------------------------------------------------
//PRESENTATION STLYE IS FORM SHEET
btnTest.TouchUpInside += (object sender, EventArgs e) =>
{
AnimateModalViewController animateModalViewController = new AnimateModalViewController()
{
ModalTransitionStyle = UIModalTransitionStyle.CoverVertical,
ModalPresentationStyle = UIModalPresentationStyle.FormSheet,
};
this.NavigationController.PresentViewController(animateModalViewController,true,null);
};
//-----------------------------------------------------------------------------------------
//UIViewAnimation-----------------------------------------------------------------------------
//RECTANGLE ANIMATION (GO LEFT AND RETURN TO STARTING POINT
PointF p0;
UIView view = new UIView();
view.Frame = new RectangleF(20,20,200,200);
view.BackgroundColor = UIColor.Green;
this.View.Add(view);
btnCoreAnimation.TouchUpInside += (object sender, EventArgs e) =>
{
p0 = view.Center;
UIView.Animate(2,0,
UIViewAnimationOptions.CurveEaseInOut | UIViewAnimationOptions.Autoreverse,
() =>
{
view.Center =
new PointF(
UIScreen.MainScreen.Bounds.Right - view.Frame.Width /2,
view.Center.Y
);
},
() => { view.Center = p0;}
);
};
//UIView ANIMATION (FADE IN FROM THE CENTER OF THE SCREEN)---------------------------------------------
PointF p1;
UIView view1 = new UIView();
view1.Frame = new RectangleF(this.View.Center.X,this.View.Center.Y,0,0);
view1.BackgroundColor = UIColor.Gray;
//DISMISS BUTTON FOR VIEW1
UIButton btnDismissView1 = new UIButton(UIButtonType.RoundedRect);
btnDismissView1.Frame = new RectangleF(318,687,133,44);
btnDismissView1.Title(UIControlState.Normal);
btnDismissView1.SetTitle("Dismiss View1",UIControlState.Normal);
//DISMISS VIEW1
btnDismissView1.TouchUpInside += (object sender, EventArgs e) =>
{
UIView.Animate(2,0,UIViewAnimationOptions.BeginFromCurrentState | UIViewAnimationOptions.CurveEaseIn,
() =>
{
btnDismissView1.RemoveFromSuperview();
view1.Frame = new RectangleF(this.View.Center.X,this.View.Center.Y,0,0);
},
() =>{view1.RemoveFromSuperview();}
);
};
//ADD VIEW1 AS SUBVIEW TO this.View
btnFadeInView.TouchUpInside += (object sender, EventArgs e) =>
{
this.View.Add(view1);
p1 = view1.Center;
UIView.Animate(2,0,UIViewAnimationOptions.BeginFromCurrentState | UIViewAnimationOptions.CurveEaseIn,
() =>
{
view1.Frame = new RectangleF(0,0,768,960);
},
() => {view1.Add(btnDismissView1);} //EMPTY, COULD BE USED FOR ACTION UPON COMPLETITION OF ANIMATION
);
};
//---------------------------------------------------------------------------------------------
//iOS built-in animations----------------------------------------------------------------------
btnCrossDissolve.TouchUpInside += (object sender, EventArgs e) =>
{
this.NavigationController.PushControllerWithTransition(animateView,
UIViewAnimationOptions.TransitionCrossDissolve);
};
//.........这里部分代码省略.........
示例12: ButtonFinished
public void ButtonFinished (ButtonView button, UIView trackingView, UITouch location)
{
double delayInSeconds = 0;
buttonDraggedToPad = false;
miniPadView.Layer.BorderWidth = 0;
CGPoint point = location.LocationInView (miniPadView);
if (miniPadView.PointInside (point, null)) {
updateScoreForDroppedButton (button);
UIView.Animate (.1f, () => trackingView.Transform = CGAffineTransform.MakeRotation (10f * (float)Math.PI / 180), async () => {
await UIView.AnimateAsync (.1f, () => trackingView.Transform = CGAffineTransform.MakeRotation (-10f * (float)Math.PI / 180));
await UIView.AnimateAsync (.1f, () => trackingView.Transform = CGAffineTransform.MakeRotation (10f * (float)Math.PI / 180));
await UIView.AnimateAsync (.1f, () => trackingView.Transform = CGAffineTransform.MakeRotation (-10f * (float)Math.PI / 180));
await UIView.AnimateAsync (.1f, () => trackingView.Transform = CGAffineTransform.MakeRotation (0));
});
}
delayInSeconds = 0.5;
var popTime = new DispatchTime (DispatchTime.Now, (long)(delayInSeconds * NSEC_PER_SEC));
DispatchQueue.MainQueue.DispatchAfter (popTime, async () => {
await UIView.AnimateAsync (0.35f, () => {
CGRect bounds = trackingView.Bounds;
bounds.Size = new CGSize (10, 10);
trackingView.Bounds = bounds;
});
trackingView.RemoveFromSuperview ();
});
}
示例13: AddMsgToView
private void AddMsgToView(AppMsg appMsg)
{
UIApplication.SharedApplication.InvokeOnMainThread(() =>
{
const int paddingh = 15;
const int paddingv = 8;
var size = new NSString (appMsg.Text).StringSize (UIFont.BoldSystemFontOfSize (14f), UIScreen.MainScreen.Bounds.Width - 80, UILineBreakMode.WordWrap);
var inner = new UILabel(
new CoreGraphics.CGRect(
(UIScreen.MainScreen.Bounds.Width-size.Width)/2,
// (UIScreen.MainScreen.Bounds.Bottom - size.Height) / 2,
(UIScreen.MainScreen.Bounds.Bottom - size.Height-80),
size.Width,
size.Height
)
)
{
Text = appMsg.Text,
Lines=0,
Font = UIFont.BoldSystemFontOfSize(14f),
TextColor = UIColor.White,
BackgroundColor=UIColor.FromWhiteAlpha(0,0),
TextAlignment = UITextAlignment.Center,
LineBreakMode=UILineBreakMode.WordWrap
};
inner.SizeToFit();
var rect=inner.Frame;
var outRect=new CGRect(rect.X-paddingh,rect.Y-paddingv,rect.Width+paddingh*2,rect.Height+paddingv*2);
var layout=new UIView(outRect){
BackgroundColor = UIColor.FromRGBA(0,0,0,0)
};
layout.Layer.CornerRadius=8;
layout.Layer.MasksToBounds=true;
layout.Layer.BorderWidth=0;
inner.Frame=new CGRect(paddingh,paddingv,rect.Width,rect.Height);
layout.AddSubview(inner);
UIApplication.SharedApplication.KeyWindow.AddSubview(layout);
UIView.AnimateAsync(0.2,()=>{
layout.BackgroundColor=UIColor.FromRGBA(0,0,0,200);
});
appMsg.State = MsgState.IsShowing;
Task.Delay(appMsg.Duration-700).ContinueWith(r => UIApplication.SharedApplication.InvokeOnMainThread(() =>
{
UIView.AnimateAsync(.5,()=>{
layout.BackgroundColor=layout.BackgroundColor.ColorWithAlpha(0);
}).ContinueWith(t=>{
InvokeOnMainThread (()=>{
layout.Hidden=true;
layout.RemoveFromSuperview();
});
});
appMsg.State = MsgState.Display;
if (msgQueue.Count == 0)
{
needGoon = false;
}
allDone.Set();
}));
});
}
示例14: BuildOptionsView
UIView BuildOptionsView ()
{
var screenWidth = UIScreen.MainScreen.Bounds.Width;
var alert = new UIView(new RectangleF(AlertMarginX, AlertY, screenWidth - 2*AlertMarginX, AlertHeight));
alert.BackgroundColor = UIColor.White;
var title = new UILabel(new RectangleF(AlertPaddingX, AlertPaddingY, alert.Bounds.Width - 2*AlertPaddingX, 40));
title.Text = "Options";
alert.AddSubview(title);
var atmsCheckbox = BuildCheckboxOption (alert, "ATMs", 60);
var branchesCheckbox = BuildCheckboxOption (alert, "Branches", 100);
var partnerCheckbox = BuildCheckboxOption (alert, "Patner ATMs", 140);
atmsCheckbox.Selected = MapOptions.SelectOwnAtms;
branchesCheckbox.Selected = MapOptions.SelectOwnBranches;
partnerCheckbox.Selected = MapOptions.SelectPartnerAtms;
var okButton = new UIButton (UIButtonType.RoundedRect) {
Frame = new RectangleF(AlertPaddingX, AlertHeight - AlertPaddingY - 44, alert.Bounds.Width - 2*AlertPaddingX, 44),
};
okButton.SetTitle ("OK", UIControlState.Normal);
okButton.TouchUpInside += (object sender, EventArgs e) => {
MapOptions = new Options(atmsCheckbox.Selected, branchesCheckbox.Selected, partnerCheckbox.Selected);
alert.RemoveFromSuperview();
FetchAndUpdate();
};
alert.AddSubview (okButton);
return alert;
}
示例15: ToastAnimationDidStop
public void ToastAnimationDidStop(string animationID,bool finished,UIView toast)
{
if (animationID.Equals("fade_in"))
{
UIView.BeginAnimations("fade_out",toast.Handle);
UIView.SetAnimationDelay(interval);
UIView.SetAnimationDuration(kFadeDuration);
UIView.SetAnimationDelegate(this);
UIView.SetAnimationDidStopSelector(new Selector("toastAnimationDidStop:finished:context:"));
UIView.SetAnimationCurve(UIViewAnimationCurve.EaseIn);
toast.Alpha=0.0f;
UIView.CommitAnimations();
}
else if (animationID.Equals("fade_out"))
{
toast.RemoveFromSuperview();
}
}