2

我正在尝试更改放置在 UIScrollView 内的 UIImageView 的位置。无论我设置什么,图像总是显示在 UIScrollView 的左上角。尝试将 X、Y 坐标更改为 200,200 之类的坐标仍会将图像置于 0,0。

单触代码:

    private void LoadPageContent(int page)
    {
        var panelScrollView = new UIScrollView();

        panelScrollView.MinimumZoomScale = 1.0f;
        panelScrollView.MaximumZoomScale = 3.0f;
        panelScrollView.MultipleTouchEnabled = true;

        panelScrollView.BackgroundColor=UIColor.Black;
        if (page == 1)
        {
            panelScrollView.BackgroundColor=UIColor.Red;
        }

        panelScrollView.ScrollEnabled = true;
        panelScrollView.UserInteractionEnabled=true;
        var ui = new UIImage (_assetImages[page], 1.0f, UIImageOrientation.Up);
        UIImageView imgView = new UIImageView(ui);

        //Position the panelScrollView in the right page on the main scrollview
        RectangleF frame = scrollView.Frame;
        PointF location = new PointF();
        location.X = frame.Width * (_numberOfPanels - 1);
        frame.Location = location;

        panelScrollView.Frame = frame;
        panelScrollView.BackgroundColor=UIColor.Green;

        imgView.Frame.X = 200; //<---- this does nothing
        imgView.Frame.Y = 200; //<---- this does nothing

    //Setting Bounds does nothing either

        imgView.ContentMode=UIViewContentMode.Center; //<--this does nothing

        panelScrollView.AddSubview(imgView);
        scrollView.AddSubview(panelScrollView);

    }

有任何想法吗??

4

0 回答 0