Following on from my last post on creating A Light status bar for iOS, I wanted to go one step further and add in a full-screen background image to my application. This is very easy without a navigation bar, but with one it’s a bit more involved so I thought a blog post would be in order.
If you have no navigation bar then all you really need to do is create an image of the right size (for each physical phone you want to support, such as 4S, 5S, 6, 6 Plus), add images to the resources directory and use them in code or XAML. With a navigation bar it’s a bit more involved as you need to split your source image into two separate images (one for the navigation bar and one for the remainder of the screen).
Then when you have the images defined you need to hook the images to the correct controls, and this is where it gets a little more complex. With a NavigationPage we need to set the navigation bar’s background to an image – but we can’t do this in regular Xamarin Forms code as the property is only available in a custom renderer, so we’ll need to create one.
First off though we need an image – I chose one I took in 2006 whilst on holiday with my family – this is the last time we were all together and it was a beautiful day. Anyhow, I extracted four images in total as shown in the following…
The red outline contains the navigation bar image (640px * 128px) and the background image (640px * 1008px) – these are both for an iPhone 5S which is what I have to develop on at the moment.
The green outline contains the two images for the landscape view, the navigation bar being 1136px * 64px, and the background image being 1136px * 576px. The navigation bar is shorter by default in landscape mode as the status bar is switched off. I believe it’s possible to override this and display the status bar, but I don’t need that so haven’t looked into it further.
I named those images as follows…
- PortraitNavBar@2x.png
- PortraitBackgrouns@2x.png
- LandscapeNavBar@2x.png
- LandscapeBackground@2x.png
With that done I then needed to write a bit of code. First up I had to ensure that the correct background image was shown for the content page – this was simply a job of overriding the OnSizeAllocated member of my content page…
protected override void OnSizeAllocated (double width, double height)
{
base.OnSizeAllocated (width, height);
if (width < height)
this.BackgroundImage = "PortraitBackground.png";
else
this.BackgroundImage = "LandscapeBackground.png";
}
The OnSizeAllocated method is called when the size changes on the phone and it provides the size of the page, so this seemed like a reasonable place to determine which image to load up.
Then I needed to add in a custom render so added a deriver navigation page as shown below…
public class CustomNavigationPage : NavigationPage
{
public CustomNavigationPage (Page content) : base(content)
{
}
}
With that defined I could then add the renderer. The purpose of this renderer is to render the background image of the navigation bar...
[assembly: ExportRenderer(typeof(CustomNavigationPage), typeof(XamFormsTestbed.iOS.Renderers.CustomNavigationPageRenderer))]
namespace XamFormsTestbed.iOS.Renderers
{
public class CustomNavigationPageRenderer : NavigationRenderer
{
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
var img = UIImage.FromBundle ("PortraitNavBar.png");
this.NavigationBar.SetBackgroundImage (img, UIBarMetrics.Default);
img = UIImage.FromBundle ("LandscapeNavBar.png");
this.NavigationBar.SetBackgroundImage (img, UIBarMetrics.Compact);
}
}
}
Originally I'd tried responding to size changes here, but then read an article that discussed the above mechanism and it appeared to work.
With all that in place I can now display a background image in the navigation bar and also have a correctly formatted image for both landscape and portrait orientations...

And there you have it – a full background image with a navigation bar. Hopefully this will help someone with their application.
1,448 comments:
«Oldest ‹Older 1401 – 1448 of 1448Gotoassignmenthelp is team of leading professional writers for Essay Help Writing Services to students all around the world. Contact us today for Best Research Paper Help at very affordable price. Under GotoAssignmentHelp we provide many types of help to the students. We are the most reliable assignment helpers. We have gained our specialization after spending most of our times in making ourselves perfect. We providing 100% plagiarism free Assignment Help. At the point when you pick our maths assignment assistance, our faculty will consider the quality and your evaluation criteria.
Thank you so much for such a quality article. Nursing is a noble profession that has emerged out of medical science. Nursing focuses on the care of ill people so that they may get well or recover from their illness as soon as possible. There is zero tolerance in the nursing assignments given to the nursing students by their professors because any mistake or confusion in the understanding of medical terms and terminologies may prove to be fatal for the patients. Now you can get Nursing Assignment Writers
If you are using a Xerox printer and showing a Xerox printer offline error, you can try these steps to fix it.
Your printer might appear offline if it can't communicate with your PC.
• Select the Start icon on the bottom left of your screen,
• Select Control Panel, and then select Devices and Printers.
• Next, right-click the printer in question and select See what's printing.
• From the window that opens, select Printer from the menu bar at the top.
• Next, choose Printer Use Online from the drop-down menu.
It is the most straightforward method to fix this error. However, if you cannot do this, you can connect with us to fix this error.
Xerox Printer Offline
SEO Company in Coimbatore SEO Agency in Coimbatore SEO Services in Coimbatore
SEO company in coimbatore
digital marketing company in coimbatore digital marketing agency in coimbatore SEO company
Digital marketing company in coimbatore
Snapchat users finally have a piece of good news to cheer upon!. Read this complete article at The Pakistan.
Permainan Sportsbook Online Terbaik memanglah sangat menyenangkan untuk di mainkan oleh bettor dan dapat memperoleh keuntungan cukup besar.
Nyatanya pasaran sportsbook sepakbola ini pasti tidak hendak jauh dari permainan olahraga sepak bola https://domainsbobet.com/ bukan? Di mana memanglah permainan sepak bola ini telah di favoritkan oleh para masyarakat, tidak cuma itu sudah sangat mendunia sekali.
This article has it all thanks for sharing. The help to write any type of document requires numerous things to consider and a lot of time too. The final services of writers would be an exception for you. Because they are fully trained and educated. You cannot expect silly mistakes or defects from them in written tasks. The group of researchers conducts an in-depth investigation by collecting relevant data from the best possible sources. Read more on Capstone Project Writers
Nice blog!This blog gives really important information.Thanks for sharing.Certified Translator
Need more advanced set of wallpapers with updated pixels create music streaming app
Singapore Translators is the best translation service provider in Singapore where a great team of capable and experienced translators offers human-based language translation for various kinds of documents like legal, medical, business, academic, and many more at a very reasonable price.
The strength an article should possess appears in your post. Nowadays, security and privacy are the utmost in this digital world. An informative as well as creative post. Businesses looking for highly functional native applications can Blockchain software development company like AppSquadz can help with it.
Hi, I am Linnea! If you need help with your assignment, I recommend you get online assistance. The Best assignment help we provide gives them good grades. Before paying for an assignment help service, feel free to get a free sample from our assignment helper. If you run into any issues, I am available to assist you.
The Doctor of Nursing Practice (DNP) program is an advanced nursing degree that helps take one’s career to the next level. Students who have graduated in a DNP program are considered to have attained more leadership qualities and highly qualified health care practitioners. Earning your DNP degree provides skills and tools that enable you to examine published evidence to inform your practice, enhance systems of care to influence patient outcomes, and make changes to improve the quality of care when needed. Read more from DNP Assignment Writers
This is a fantastic post that is both knowledgeable and educational. Thank you so much for letting us in on your wonderful thoughts. If you're not sure whether or not to use our assignment writing service, contact one of our highly qualified and experienced authors for advice. Our Online Assignment Help service will be available to all students 24 hours a day, 7 days a week.
Thanks for informative articles, it’s an interesting updates. Looking forward to more of the updates on next publish. Its a better growth and hard work. Thanks so much for sharing. Meanwhile, visit latest news on rhema university post utme form
Hello,
Absolutely an informative post, I am a student and share some valuable information for others to get matlab assignment help across the Globe. I found this matlabworks.com which provides world class Matlab Project Help , MATLAB IMAGE PROCESSING ASSIGNMENT HELP , MATLAB ELECTRICAL ASSIGNMENT HELP to students globally. Best of Luck!
hire best writers from UK site and score well in exams with guaranteed results.
do my essay UK
buy cheap essay
Hello Writer, such a nice article written.
Good job thanks for posting such good content, We have a skilled professional digital marketing team with 4+ years of experience. Also, our team gives 100% support every time. If you have any requirements regarding Digital Marketing Company then you can contact us at +91-8574546649
Thetuorshelp Finance homework help Finance homework help is prepared to help the students in understanding all the important concepts which are involved in financing. In finance homework we will deal with all the basic and important aspects of finance https://thetutorshelp.com/finance-homework-help.php
Finance Homework Help
We appreciate go work and for sharing such informative content. Would you be interested in nursing essay help in your assignment from our trained experts that will deliver content that is plagiarism free, Read more from Nursing Essay
Amazing one!
Worth Stuff thanks for sharing.
Scholarship practice test Victoria and NSW
free for Australian children's to improve studies and carriers
Superb post!!! worth it
GPS vehicle tracking system in Coimbatore
Excellent post!!!
Smash repair Dandenong
Hi, I am John Smith I am Web Developer, It is an amazing blog thanks for the sharing the blog. Frantic infotech provide the ios real estate app development such as an information about software development for costumer service. Frantic infotech also provide the ios event app development. Theve delopment of advanced web applications is Orient Software’s specialty and we will successfully fulfill all your web application development requirements, from small-sized to wider-ranged projects.
hello,
Thank You For great Sharing information. once again thank you.
Checkpoint Endpoint Security VPN
Please visit above link for best antivirus and related information. Please check above link.
Purchase the best best fitness tracker device only in 2000 in India. Offer limited
get the tracker now. Best deal to buy fitness tracker. Get best fitness band in india under 2000 to kickstart your fitness in cheapest price. Buy the best fitness band in India. best fitness band in india under 2000
Nice post.
3d walkthrough china
Such a very useful article.Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article.
3D Interior Design
we at write my essay for me in UK offer online essay help service with affordable price.
http://kumalaapk.com/
http://gacor69slot.com/
http://dicesicbo.com/
Get high-quality 3D Rendering service in China with timely delivery, and lowest quote challenge for 3D Architectural rendering for Architects & Developers, 3d interior designs china, 3D Animation Movie, 3D Product Design & Modeling for Manufacturers, 3D Medical Illustration and Visualization.
Essay writing is a part of academic study and every Academics student has to write a different essay as their assignment. Essay writing is not a cup of tea for everyone as it is quite different from other writing. Too much assignment pressure on essay writing hampered the concentration of the academic students. If you are one of them then contact a custom writer to have the best content in essay writing. If you are thinking about who had to find the best solution for essay writing then contact the experts of essay writing help. In exchange for a pocket-friendly service charge, the expert writers of this website will bring you the best essay content without any grammatical errors. No other solution will be best for you as with the help of the expert writers of this website you can handle both assignment pressure and your studies simultaneously. So do not waste your valuable time just contact the experts on this website. Surely will climb the success ladder with the help of expert writers on the essay writing help website.
https://www.onlinetutorhelps.com/essay-writing-help/
Essay Writing Help
Excellent for this specific beneficial blog post. I am surprisingly happy to seek out this form of relevant information. geography jamb past questions & solutions in pdf
I have been looking for this blog post for use. I am grateful that you have share this useful contents. past questions for social studies pdf
hello are you looking porn website so don't worry our website free porn video downloads so join our site for free video downloads
If you need cheap online assignment help? Then Global Assignment Help offers the most affordable services with top-quality assignment help in all over the world. Our superior quality and 24*7 Expert assistance is very helpful to the students. Our native skilled experts cover various assignments like management assignment help, computer network assignment Help, programming assignment Help, engineering assignment help, and many more.
Global Assignment Expert provides various facilities such as Expert Guidance, Improved Grades, Customised content, Plagiarism-Free Work, Stress Reduction, and many more. Our Online Assignment Help services are such a valuable resource that can enhance your academic life. They will offer a Learning opportunity and help you manage your time. If you want to improve your grades then Global Assignment Help can be a game-changer in your academic journey.
Global Assignment Expert provides various assignment help online Finance Assignment Help is one of them. It comes under accounts, which means wealth management in other terms managing money. The assignment expert must have knowledge of accounts as well as having experience in finance. To complete the assignment we have highly experienced experts. We offer our assignments at an affordable price range. Global Assignment Help also provides premium services in terms of quality and price.
Speakeasy Internet Tester is a game-changer for internet speed checks online speed checker for speakeasy
Random receh
Slot Online
Slot Gaming
Deposit Pulsa Tanpa Potongan
Casino Online
Bonus New Member 100%
Post a Comment