zoukankan      html  css  js  c++  java
  • 3.monotouch 界面布局

    1.资源图片的放置。

    布局界面的时候需要将图片放到项目中,monotouch中图片可以直接加到项目根目录下,但是图片过多时就会显的比较乱。最好的做法就是放到Resources 文件下。该文件中的图片属性必须确保Build action 为BundleResource,Resources文件夹下不可以分子文件目录存放图片。

    2.布局时,通常需要设置一个大的背景,monotouch中没有面板的概念,通常最基本的是UIView,可以用它来做分块。一个xib的顶级父容器就是UIView,由于UIView的Background在属性栏中只能设置颜色,不带有图片,所以可以选择使用一个UIImageView作为背景,设置UIImageView的大小坐标与父容器相同。如果一个界面上排列的元素过多,鼠标无法准确点到时,就需要用到Placeholders。如图所示:

    eg1:                                                             eg2:

                 

    当前页所有元素都会排列出来。

    3.使用代码添加控件到View中,例如添加按钮。

    UIImage img=UIImage.FromFile("button_top.png");
    
    UIButton btnRefresh=new UIButton ();
    //设置坐标大小
    btnRefresh.Frame=new RectangleF (700,5,95,32);
    btnRefresh.Font = UIFont.SystemFontOfSize (12);
    btnRefresh.SetBackgroundImage(img,UIControlState.Normal);
    btnRefresh.SetTitle("Refresh",UIControlState.Normal);
    btnRefresh.SetTitleColor(UIColor.White,UIControlState.Normal);
    
    //点击事件
    btnRefresh.TouchUpInside+= btnRefresh_Click;
    this.View.AddSubview(btnRefresh);
    
    void btnRefresh_Click (object sender, EventArgs e)
    {
        LoadData();
    }

    4.从View中删除控件
    btnRefresh.TouchUpInside-= btnRefresh_Click;
    btnDelete.RemoveFromSuperview();
    
    
  • 相关阅读:
    From MSI to WiX, Part 2
    From MSI to WiX, Part 1
    WIX Custom Action (immediate, deffered, rollback)
    SVN: revert all command
    HowTo: SVN undo add without reverting local changes
    “Assign Random Colors” is not working in 3ds Max 2015
    CruiseControl.NET : svnrevisionlabeller
    JSON parser error with double quotes
    How to: Extract files from a compiled setup.exe created by Inno setup
    虚拟账号ftp服务器
  • 原文地址:https://www.cnblogs.com/Cindys/p/2972683.html
Copyright © 2011-2022 走看看