When you use TableView, the background color of the default selected cells is dimmed, as shown in the following figure:
1, using a custom background color
You need to customize the background view when UITableViewCell is selected and set its color
Import UikitClass Viewcontroller:uiviewcontroller, Uitableviewdelegate, Uitableviewdatasource {var tableview:u
By default, the style of the navigation bar Uinavigationcontroller is simpler if you want to use code to modify the style.
1, modify the navigation bar background color
Modify the navigation bar background colorSelf.navigationcontroller? Navigationbar.bartintcolor =Uicolor (red:55/255, green:186/255, blue:89/255, alpha:1)
2, modify the navigation bar text color
One, the general theme color point of useThe app will set its theme color before publishing to unify the style of the app (there may be multiple sets of topics). There are several aspects to the theme color setting, as follows:1.TabBar section, set picture highlighting, text height color2.NavigationBar section, set the navigation bar
Uitabbaritem in the development of a very common use it can be used to set the font color and picture settings, and so on, let's take a look at the iOS development of the Swift tab bar button Uitabbaritem style modification (icon text size, color, etc.) example, the details are as follows.Recommended dimensions and maximum supported dimensions for 1,tabbaritem pi
. Sharedapplication(). Statusbarstyle =. Lightcontent // status bar background color Adding a view to the window remains at the forefront, and it is important to note that the view is created after the root view controller is set up, otherwise it will not appear.let statebarblockview = UIView(frame: cgrectmake(0, 0, window!). bounds. Width, )) Statebarblockview. backgroundcolor = uicolor. Blackcolor() window?. addsubview(st
1. Set the background color using the built-in color of Uicolor
12
varpage = UIView()page.backgroundColor = UIColor.greenColor()
2. Set the custom color
1
page.backgroundColor = UIColor(red: 0x37/255, green: 0xba/255, blue: 0x46/255, alpha: 1)
3, set the background picture (if the picture is too smal
Extensionuiimage{/** Gets the pixel color value in the picture-parameter pos: position in picture-returns: Color value */func Getpixelcolor (POS:Cgpoint) (Alpha:CGFloat, Red:CGFloat, Green:Cgfloat,blue:CGFloat) {Let pixeldata=Cgdataprovidercopydata (Cgimagegetdataprovider (Self. cgimage)) Let data:unsafepointerUint8> =Cfdatagetbyteptr (pixeldata) Let Pixelinfo:int = ((Int (Self.size.width) * INT (Pos.y)) +
Recommended dimensions and maximum support dimensions for 1,tabbaritem pictures
Below is the tab bar (Uitabbar) In the tab button icon in 1x, 2x, 3x will not compress the size of the deformation:
@1x: Recommended x 25 (max: 32 x)
@2x: Recommended x 50 (max: x 64)
@3x: Recommended x 75 (max: 144 x 96)
Below is 2x, the left use x 50 of the picture, the right to use the x 64 picture, you can compare:
Import UikitClass Maintabviewcontroller:uitabbarcontroller{Overrid
When we do the pop-up window or display the label string, we often use the special processing such as changing the font color to large,A function is provided in SwiftNsmutableattributedstringIntroduction to How to usevar main_string = "Hello World"//definition stringvar string_to_color = "World"//action stringvar range = (main_string as NSString). Rangeofstring (String_to_color)//operationvar attributedstring = nsmutableattributedstring (string:main_s
When we use the Search bar (uisearchbar), if you set it to "shows Cancel button", there is a Cancel button on the right side of the input box (the title text is cancel).
Sometimes we want to change this button to something else, like "search." Although Searchbar does not provide a way or a property to directly modify the text of this button, we can implement it in a different way.
1, modify the text of the Searchbar Cancel button
First get the cancellation button in the Searchbar, and the
object.Let MyTextField = Uitextfield (frame:cgrect (0.0, 0.0, 200.0, 40.0))The UITableView and Uitextfield objects here have the same functionality that you used in objective-c. You can use them in the same way, including accessing properties or calling methods in their own classes.For the sake of unification and simplicity, the Objective-c factory method is also mapped in Swift as a convenient initialization method. This mapping allows them to use t
(frame: CGRectZero, style:. Grouped)
To ensure consistency and simplicity, the Objective-C factory method is automatically mapped to the Swift language for convenient initialization when being imported to Swift. For example, in Objective-C, call a factory method as follows.
UIColor * color = [UIColorcolorWithRed: 0.5 green: 0.0 blue: 0.5 alpha: 1.0];
In
About Swift on SwiftOfficial document translation, for reference only, my English is not good, learning while translating, do not like to spray.Swift is a new programming language for IOS, OS X, WatchOS, and TvOS apps that builds on the best of C and Objective-c, WI Thout the constraints of C compatibility. Swift adopts safe programming patterns and adds modern features to make programming easier, more flex
, including accessing properties or calling methods in their own classes.For the sake of unification and simplicity, Objective-c's factory approach is also mapped to a convenient initialization method in Swift. This mapping allows them to use the same straightforward initialization method. For example, in objective-c you might call a factory method as follows:
Copy Code code as follows:
Objective-c
Uicolor *
Why is swift so popular ?, Swift fire?
First of all, swift is very popular. It ranks 16 in the month when it comes out. Why is it so hot?
Is it because of the Apple brand? Or other reasons?
As a code farmer (working for more than 15 years), I will talk about my personal opinions.
There are many excellent PC-side development languages: JavaScript, Python, and Ruby
unification and simplicity, the Objective-c factory method is also mapped in Swift as a convenient initialization method. This mapping allows them to use the same simple and straightforward initialization method. For example, in objective-c you might call a factory method like this:
Objective-c
Uicolor *color = [Uicolor colorwithred:0.5 green:0.0 blue:0.5 alpha:1.0];
In
This section includes the following:
String (Strings)
Value (Numbers)
Collection Class (Collection Classes)
Error (Errors)
Foundation data type (Types)
Foundation Function (Foundation Functions)
Core Foundation
As part of OBJECTIVE-C Interoperability (interoperability), Swift provides a fast and efficient way to process COCOA data types.Swift will automatically convert some of the objective-c types to
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.