亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

是否可以調整 UITabbarcontroller 的子視圖大小?

是否可以調整 UITabbarcontroller 的子視圖大小?

C#
aluckdog 2023-07-09 16:38:01
所以我得到了這樣的故事板布局:UITabbarcontroller -> child1 -> child2我能夠在 child2 的 viewdidload 方法中的 UITabBar 上方動態添加狀態欄,如下所示    StatusBar.BackgroundColor = Appearance.ErrorColor.BackgroundColor;    var window = UIApplication.SharedApplication.Delegate.GetWindow();    window.AddSubview(StatusBar);現在的問題是,當我說狀態欄存在時,我希望任何孩子的內容都向上移動我嘗試了很多排列和方法,包括增加狀態欄的大小和減小子視圖的大小,但都無濟于事。對此提供幫助將不勝感激!    UIView.Animate(0.2, () => {        var frame = this.View.Frame;        this.View.Frame = new CoreGraphics.CGRect(frame.X, frame.Y, frame.Width, frame.Height - 40);        this.View.InvalidateIntrinsicContentSize();        this.View.LayoutIfNeeded();        this.View.SetNeedsLayout();    });
查看完整描述

1 回答

?
慕森卡

TA貢獻1806條經驗 獲得超8個贊

有可能,但是前提是View的Y坐標正好是40,當你隱藏狀態欄的時候, Y坐標就變成0了,整個View就會上移。


一般來說,Tabview 子視圖的X和Y(0,0)坐標從 開始,而不是從 開始(0,40),因此下面的代碼可能不起作用。


UIView.Animate(0.2, () => {

    var frame = this.View.Frame;

    this.View.Frame = new CoreGraphics.CGRect(frame.X, frame.Y, frame.Width, frame.Height - 40);


    this.View.InvalidateIntrinsicContentSize();

    this.View.LayoutIfNeeded();

    this.View.SetNeedsLayout();


});

不過代碼是沒有問題的,你只需確保子視圖的大小從(0,40)開始,就可以看到效果了。


=======================================更新============ =====================


如果您想要轉換視圖,請按如下方式編碼:


UIView.Animate(2, () =>

{

    var frame = this.View.Frame;

    this.View.Transform = new CoreGraphics.CGAffineTransform((System.nfloat)0.8, 0, 0, (System.nfloat)0.8, 0, 0);

    //change contained parameter can modify the level of transform , and even can back to normal status

    this.View.InvalidateIntrinsicContentSize();

    this.View.LayoutIfNeeded();

    this.View.SetNeedsLayout();

});

回到正常狀態,替換為:


this.View.Transform = new CoreGraphics.CGAffineTransform(1, 0, 0, 1, 0, 0);


查看完整回答
反對 回復 2023-07-09
  • 1 回答
  • 0 關注
  • 130 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號