如何从Xamarin.ios访问UIImagePickerController Shutter UiButton

问题描述 投票:0回答:1

我想从xamarin.iOS应用程序访问Shutter UiButton,所以我可以对它进行一些更改,但我无法找到它。

所以我试图在xcode中重新创建UIImagePickerController项目,我发现它使用此代码,我能够做的更改。 xamarin.iOS有不同的视图层次结构吗?

 for (index,v) in self.imagePicker.view.subviews.enumerated()
                    {
                        print("layer \(index) : \(v)")
                        for (index2,vv) in v.subviews.enumerated()
                        {
                            print("layer \(index, index2) : \(vv)")

                            for (index3,vvv) in vv.subviews.enumerated()
                            {
                                print("layer \(index, index2, index3) : \(vvv)")

                                for (index4,vvvv) in vvv.subviews.enumerated()
                                {
                                    print("layer \(index, index2, index3, index4) : \(vvvv)")
                                    for (index5,vvvvv) in vvvv.subviews.enumerated()
                                    {
                                        print("layer \(index, index2, index3, index4, index5) : \(vvvvv)")

                                        for (index6,vvvvvv) in vvvvv.subviews.enumerated()
                                        {
                                            print("layer \(index, index2, index3, index4, index5, index6) : \(vvvvvv)")

                                            if (vvvvvv as? UIButton != nil)
                                            {
                                                var t =  String(describing:type(of:vvvvvv))
                                                if(t == "CUShutterButton")
                                                {
                                                    print("is button CUShutterButton")
                                                    (vvvvvv as! UIButton).setTitleColor(UIColor.red, for: UIControlState.normal)
                                                     (vvvvvv as! UIButton).backgroundColor = UIColor.red
                                                    v.frame = CGRect.init(x: 0, y: 0, width: 500, height: 500)
                                                    for (vvvvvvv) in vvvvvv.subviews
                                                    {
                                                          vvvvvvv.backgroundColor = UIColor.red
                                                    }
                                                }

                                            }
                                        }
                                    }
                                }
                            }
                        }

                    }

Image : can't find the UiButton from vs

xamarin.forms xamarin.ios custom-renderer ios-camera
1个回答
0
投票

Xamarin没有不同的视图层次结构。你的问题在于:

                                                var t =  String(describing:type(of:vvvvvv))
                                            if(t == "CUShutterButton")

我不确定你是如何将它转换为Xamarin(它也可能影响结果),但类的类型的字符串描述可能不同。因此,您需要列出所有字符串,找到正确的字符串并在if语句中使用它。

© www.soinside.com 2019 - 2024. All rights reserved.