• 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();
    
    
  • 相关阅读:
    NPOI json转Excel DataTable转Excel ,Excel转DataTable
    sqlhelper;
    C# DataSet数据导入Excel 修正版- .net FrameWork 4.0以上
    asp.net core 教程(七)-异常处理、静态文件
    asp.net core 教程(六)-中间件
    asp.net core 教程(五)-配置
    jQuery_3_过滤选择器
    jQuery_2_常规选择器-高级选择器2
    jQuery_2_常规选择器-高级选择器
    jQuery_2_常规选择器-进阶选择器
  • 原文地址:https://www.cnblogs.com/Cindys/p/2972683.html
Copyright © 2020-2023  润新知