Did anyone already discovered how to add this little 'button' when using modalviews in iOS 13?
https://i.stack.imgur.com/g5KnA.png
it was done! with
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"btn_orange"]];
CGFloat width = 75.0;
CGFloat height = 5.0;
imageView.frame = CGRectMake(self.view.frame.size.width/2 - width / 2, 6, width, height); //change height and width accordingly
[self.navigationController.navigationBar addSubview:imageView];
Related
I'm tring to match the whole screen in AR.JS, but I'm confused some options in AR.JS, here are my options right now, but these settings cannot make canvas full screen.
const width = window.innerWidth;
const height = window.innerHeight;
let arToolkitSource = new THREEx.ArToolkitSource({
sourceType: "webcam",
sourceWidth: width,
sourceHeight: height,
displayWidth: width,
displayHeight: height,
});
let arToolkitContext = new THREEx.ArToolkitContext({
cameraParametersUrl: "data/data/camera_para.dat",
detectionMode: "mono",
canvasWidth: width,
canvasHeight: height,
maxDetectionRate: 60,
});
I am new to xamarin.forms. I want to get height,width and resolution of my mobile programmatically in xamarin.forms. Please help to resolve this.
Recently Xamarin.Essentials NuGet pakage was released and there is a useful class DeviceDisplay in there that should handle this task for you.
The documentation can be found here.
Usage example:
// Get Metrics
var metrics = DeviceDisplay.ScreenMetrics;
// Orientation (Landscape, Portrait, Square, Unknown)
var orientation = metrics.Orientation;
// Rotation (0, 90, 180, 270)
var rotation = metrics.Rotation;
// Width (in pixels)
var width = metrics.Width;
// Height (in pixels)
var height = metrics.Height;
// Screen density
var density = metrics.Density;
I need a square block of 20% of the screen,
If i get a width of 100 DP then i also need height of 100 DP.
How to achieve this in android with the use of weight?
You can do like this
public void setImageSize(byte[] imageThumbnail)
{
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
Bitmap bitmapOrg = new BitmapDrawable(getResources(), new ByteArrayInputStream(imageThumbnail)).getBitmap();
int width = bitmapOrg.getWidth();
int height = bitmapOrg.getHeight();
float scaleWidth = metrics.scaledDensity/5;
//set image in imageView
imageView.setImageBitmap(bitmapOrg);
//set imageView dynamic width and height
imageView.getLayoutParam().width = scaleWidth;
imageView.getLayoutParam().height= scaleWidth;
}
Or
Maybe try a different approach...you can create SquareImageView to scaling of images to screen density of width and height.
when I do
paper.setup(imageCanvas);
the width and height of imageCanvas changes from 2048 * 1536 to 681 * 511 I tried to to understand the code by debugging it and
_setViewSize: function(size) {
var element = this._element,
pixelRatio = this._pixelRatio,
width = size.width,
height = size.height;
element.width = width * pixelRatio;
element.height = height * pixelRatio;
if (pixelRatio !== 1) {
if (!PaperScope.hasAttribute(element, 'resize')) {
var style = element.style;
style.width = width + 'px';
style.height = height + 'px';
}
this._context.scale(pixelRatio, pixelRatio);
}
},
is the area where it changes the size of the element by multiplying it by pixelRatio, which is somehow 0.3330000042915344.
Can anybody explain why paperjs would try to change the dimensions?
This is hilarious!
I figured out why the pixelRatio is 0.333... it is because I zoomed out the browser and hence it was changing the canvas size.
Can any body give me the solution for displaying UINavigationItem prompt text in 2 lines?
There is not a built-in way to do this. Below is a work-around that seems to work pretty well that I put together from stackOverflow post UINavigationItem with prompt and activity indicator
Here is a simulator screen shot of what it creates:
Note that since the text is a UILabel you can modify its color, font, or anything else too.
// I have this code in viewDidLoad
UIView *viewContainingPrompt;
UIBarButtonItem *promptButtonItem;
// Configuring the prompt title of the navigation bar so it is present but empty
[self.navigationItem setPrompt: #""];
// We will create a UIBarButtonItem that has a custom view (viewContainingPrompt).
// A subview of viewContainingPrompt will be a UILabel (headerLabel)
// We need to have this "intermediate" view to position the label at the right position
// (the UIBarButtonItem ignores the origin and height of its custom view)
viewContainingPrompt = [[UIView alloc] initWithFrame: CGRectMake(0, 0, 0, 85)];
viewContainingPrompt.autoresizingMask = UIViewAutoresizingFlexibleWidth;
// Choose a width that puts 10 points on either end...
CGFloat labelWidth = self.navigationController.navigationBar.bounds.size.width - 20.0;
// Note that the '-60' below is determined by the width of the back button
// If someone can figure out how to determine this width at runtime this code
// would be much more robust.
UILabel *headerLabel = [[UILabel alloc] initWithFrame: CGRectMake(-60,-8,labelWidth,36)];
headerLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth;
headerLabel.text = #"A quite long prompt string that will wrap to a second line to demonstrate multiline prompt.";
headerLabel.font = [UIFont systemFontOfSize: 14];
headerLabel.numberOfLines = 0; // Zero gives as many lines as will fit, could be 2
headerLabel.backgroundColor = [UIColor clearColor];
headerLabel.textColor = [UIColor colorWithRed: .1 green: .1 blue: .2 alpha: 0.8f];
headerLabel.shadowColor = [UIColor colorWithRed: 1 green: 1 blue: 1 alpha: 0.5f];
headerLabel.shadowOffset = CGSizeMake( 0, 1 );
headerLabel.textAlignment = UITextAlignmentCenter;
[viewContainingPrompt addSubview: headerLabel];
//[headerLabel release]; // Uncomment if not using ARC
promptButtonItem = [[UIBarButtonItem alloc] initWithCustomView: viewContainingPrompt];
self.navigationItem.leftBarButtonItem = promptButtonItem;
self.navigationItem.leftItemsSupplementBackButton = YES;
//[viewContainingPrompt release]; // Uncomment if not using ARC
//[promptButtonItem release]; // Uncomment if not using ARC
I would appreciate anyone's feedback on how to figure out the width of the back button during execution so that width did not have to be hard coded.
As it is I do not think there are any private APIs or other illegal code contained.