I start learning Swift and try to fulfill using one image picker change button image when users trigger one of three buttons.
I watch online resource and understand how to use one image picker for changing one button image
But now I have three buttons, and each of them should have the ability to use image picker and change their own button image.
My solution for this is every time when the button is clicked and image picker is called, I set the UIImage outside the function equal to the info image
At meanwhile, knowing that image picker has triggered because the button was pushed down, I put a line for set-button-image with that UIImage in the button (IBAction function).
Below is my source code. Somehow the way I wrote will not update the button's image correctly.
Let me know if any information is missing or confused. Any advice or knowledge will be helpful, thanks.
sourceCode1
sourceCode2
main page
after clicking the add button the library shows
after select image, the button image shows all white
after clicking the white part, the image somehow shows
If I click another button, the button change like the first button???
Related
I see many posts explaining how to display a label after clicking on a button but it seems nobody has raised the question of how to actually display the label text directly ON the button itself.
I am coding for the AppleWatch and due to the small screen size, it would seem that saving space and actually having the label display on the button instead of above or below or to one of the sides to be something of a perfect solution.
Specifically, what I am trying to do is create a tap counter with the incrementing number be on the button itself. Tap the number (or button) and it increments by one.
Possible?
You can create a label with transparent background, and place it on top of a button.
However, this is not an ideal solution: rather than displaying a label on top of a button, you could change the text of the button itself. This way you would have the same visual effect with fewer objects on the screen:
button.setTitle("Text you wanted on the label", forState: .Normal)
I have created a GUIDE script with 5 push buttons. Each button creates a different graph for given data. I would like every time I push one of the buttons (let's call it Button1), the button to look like it is pushed or maybe change color or title (I would prefer it to look pushed). When a different button(let's call it Button2) is pushed I want Button2 to look pushed and Button1 to look like it was initially.
Also when I plot figures and I use a title on top of the figure, GUIDE cuts the top part of the title. Is there any way to have the title on the inside of the figure or maybe closer to the top axis so that all of it is visible?
(HARD) In the ButtonDownFcn callback for each button, put code that sets the BackgroundColor property. (You can see all of the available properties for any control by choosing View/PropertyInspector in the main menu for GUIDE.) Since you only have 5 buttons, the easiest way to get what you want is to just copy and paste code between them, with appropriate changes.
Pseudocode for Button 1:
Button1.BackgroundColor=PushedColor
Button2.BackgroundColor=NonpushedColor
etc for rest of buttons
(EASY) Use a group of radio buttons instead. They do what you want, automatically.
To reposition the title, you just change the Position property of the title's text box.
I am not a iOS developer. I am working on designing GUI for an iOS application to be developed using Appcelerator Titanium.
As far as all the other buttons are concerned, they can be provided with a .png image to style them. But this one type of button which has dynamic text, and thus can have width of various sizes as shown in the image below.
The screenshot is from Instagram iOS app. It shows the button in navigation bar named Camera which is the name of the folder from which image being cropped resides. In the app I'm designing for has a button with same functionality.
I just want to know whether it is possible to add custom styling for this particular type of button.
Thanks.
yes you can create a button and set the backgroundImage for the button to be whatever you want
http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.UI.Button
third paragraph
You can specify background images for each state, as well as button text and a button icon. On iOS, there are button styles which define appearance for each state, even if no button images are set.
backgroundLeftCap Property
Simple answer: yes you can add custom styling to this button. As for the varying width, the background image will stretch to fill it.
Probably a silly question here but I have been trying to find this for about an hour now. How do I create the circular red button with an 'x' that appears when navigating pages in safari for example. And is there an 'official' name of such a button type?
Screenshot
Thanks !
You'll have to create a button eIther from scratch or from the screenshot in an Image editor like photoshop and then import it into your project and set a button's image to the name of the image. There is no official name for this button and you can't add it to your app using a key or special method.
Please help me how to change the selected background image dynamically please give me sample example...
I Need to change My application background image when i select the particular image from drop-down list, If click on apply button that image will be display in the background.
Thanking you
I suggest you try hooking up your button to a listener, then using Background to create your background before using setBackground() to change the background.
If this doesn't update the way you want, overwrite the layout() method in your screen and call the setBackground() in there, then call UIApplication.getUIApplication().relayout() to get it to layout the screen again (be sure to do it in a synchronize block!)
Good luck!