I am presenting a viewController with transparent background. But the components on that viewController is invisible when it is presented. A blank viewController is seen.I have given alpha value and black background color.
This is my code when i call the transparent viewController
if indexPath.row==0
{
let modalViewController = PopUpViewController()
modalViewController.modalPresentationStyle = .overCurrentContext
present(modalViewController, animated: true, completion: nil)
}
But there is a orange color UIView present on this Controller which is invisible Thanks in advance
You just have to present your second Viewcontroller, which has a transparent background, modally. with the following config:
and that's the result :
for those who may not familiar with Opacity: in the situation like this, for transparency, it's better to use Opacity instead of Alpha
You can take two view one as outerView (Transparent black) and innerView( OrangeView) , note that both view are in same hierarchy. (as in screen shot)
Default View of viewController background color should be clearColor.
OuterView should having transparent black background.
On Segue presentation property in Attribute inspector of Segue should be Over Full Screen as shown in image.
it will show on running.
Related
Is there a good way to hide the up down arrows in the picker default style. I am using ios 16. It seems that the older version does not have such arrows.
Also, is there a setting to set the picker's background to the same style as the datepicker in the image without manually setting the background and radious?
I have been struggling on this small feature and tried googling for a few hours but no luck. Any idea will be appreciated
The suggested Menu solution works well if you only have a few options. The problem I've experienced with the Menu solution is that if there are very many options the Menu doesn't automatically scroll to the currently selected option the way the Picker does.
The solution I've used is to use ZStack to place an opaque picker on top of a custom view (my "label"). Setting the opacity modifier on the Picker to 0.025 makes it invisible on your device but it will still trigger when you tap it.
This way you get all the native functionality of the Picker (including scrolling to the selected option) and you can make the label look any way you want without having to create your own custom picker.
Here's the code:
ZStack {
// Custom picker label
Text("\(value)")
.font(.title)
.foregroundColor(.blue)
.styleDataEntry(colorScheme: colorScheme) // a custom formatter View extension
// Invisible picker
Picker("", selection: $value) {
ForEach(0 ..< 200) { option in
Text("\(option)").tag(option)
}
}
.pickerStyle(.menu)
.opacity(0.025)
}
I am using Swift 5.3 on MacOS 11.01 and created a new "Multiplatform" app for iOS 14.2. I created custom color assets for light/dark modes but am having trouble getting the light mode background color to show on my TabView. The TabView dark mode background color appears just fine.
The light mode background color appears perfect in Xcode Preview, but when I run the app in the Sim or on my device, the Tab Bar background color is clear in light mode, but shows the correct color for dark mode.
I use the same color assets for coloring my NavigationView and both the light and dark mode colors appear correctly when the corresponding modes are selected.
Is there something obvious I am missing here with the latest SwiftUI 5.3 and color assets?
I am using the following code within .onAppear in the TabView
UITabBar.appearance().barTintColor = UIColor(named: "barBackground")
Note that "barBackground" is the custom color set I created to add a light/dark mode background colors to both the NavigationView and TabView.
Happy to furnish additional info if this isn't clear. Thanks!
It is a bit late to do it in .onAppear, appearance should be changed definitely before affected view is created, so do it in init
init() {
UITabBar.appearance().barTintColor = UIColor(named: "barBackground")
}
I can't change the colour of my navigation bar to transparent. All the other view controllers in my project are fine, only this one. This particular view controller has a scroll view and it is presented by Segue.view
I use the following code in viewDidLoad()
self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: UIBarMetrics.default)
self.navigationController?.navigationBar.shadowImage = UIImage()
self.navigationController?.navigationBar.isTranslucent = true
This is the identity inspector for the view controller
I found the solution. My background image was inside my View. I put it in the wrong place. see below for correct way
I want to include cocos2d scene besides UIKit GUI elements in my app using kobold2d library, so it should take just part of the screen.
I alter cocos2d glview size like this when initializing the first layer:
UIView * glView = [[CCDirector sharedDirector]view];
CGRect rct = CGRectMake(100, 100, 300, 400);
[glView setFrame:rct];
The view is displayed properly until I change orientation, then glview again becomes fullscreen. Is there a way to disable this behaviour?
XCode 4.5.2, iOS 6, Kobold2D 2.04
Calling reshape after setting the frame might help:
UIView * glView = [[CCDirector sharedDirector]view];
CGRect rct = CGRectMake(100, 100, 300, 400);
[glView setFrame:rct];
[glView reshape];
Now after some experiments I kind of found solution, please correct me if I am wrong. At least this worked for me, hope someone else makes use of it either.
CCDirectorIOS is a UIViewController, and it is usually being set as a rootViewController of app window.
Looks like [window rootViewController] is responsible for making it's view fullscreen every time orientation changes, thus forcing all children to layout (I knew that!!! %).
Therefore, to avoid glView shrinking to the whole window now and then, give window another UIViewController as a rootController, not the CCDirector. That another UIViewController should have it's own brand new UIView. This new rootView is what this rootViewController can resize however he wants, leave alone our glView. Now, assign director as a child of rootController and assign glView as a child of a rootView.
Set glView to size You want - and off we go! Now when rootView resizes, glView doesn't. In my case it still had to resize while maintaining free space proportions so i used setAutoresizingMask on it. please gurus tell what You think.
known caveats:
rootController and navController of KKAppDelegate not used except for proper initial orientation
this raises bar of least ios version to 5 because of addChildViewController: method
the code inside app's AppDelegate (suppose ARC is ON):
-(void) initializationComplete
{
#ifdef KK_PLATFORM_IOS
RootViewController * rootvc = [[RootViewController alloc]init];
UIView * rootView = [[UIView alloc]init];
[rootvc setView:rootView];
[rootvc.view setBackgroundColor:[UIColor blueColor]];//to see views in colors
[window setRootViewController:rootvc];
[rootvc addChildViewController:[CCDirector sharedDirector]];
UIView * glview = [[CCDirector sharedDirector]view];
[rootvc.view addSubview:glview];//[[CCDirector sharedDirector]openGLView]];
CGRect glRect = CGRectInset(rootvc.view.bounds, 50, 50);//our glview frame is smaller than rootView frame
[glview setFrame:glRect];
[glview setAutoresizingMask: UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth];//so the view size follows window's size even though it's not fullscreen
#endif
}
I have added the UIScrollView into the COCOS2D game engine using
[[[CCDirector sharedDirector] openGLView] addSubview: tempScrollView];.
On that scroll view I have added a image view and a buttons. My problem is that the scroll view is scrolling vertically only. I want the UIScrollView to scroll horizontally only. Also I want the images to be rotate as well. I have tried the view transform property but its not working in my case.
Does any body know how to do this in cocos2d?
Horizontaly only ? try to change contentsize. e.g.:
ccp(5000,winsize.height)